Skip to main content

Migrate ScrollLock from Polaris React

Remove ScrollLock when its owning Polaris overlay is migrated. Keep custom scroll locking only for custom overlays with complete focus and dismissal behavior.


Anchor to Choose the destinationChoose the destination

Polaris ReactPolaris web componentsMigration type
ScrollLockRemove for Polaris overlays. Use a custom implementation only for custom overlays.Remove

Anchor to Map scroll-lock responsibilitiesMap scroll-lock responsibilities

Polaris React usagePolaris web componentsMigration notes
Lock while a modal is opens-modalRemove the separate lock and verify that background content can't scroll or receive focus.
Lock while a popover is openUsually removePopovers shouldn't normally freeze the page.
activeOverlay visibility or command stateKeep one source of truth and restore scroll position when custom workflows close.

Anchor to Migrate the call siteMigrate the call site

  1. Find every ScrollLock consumer and identify which behavior, if any, still depends on it.

  2. Migrate those dependent components or behaviors first.

  3. Delete ScrollLock and its now-unused state or helper code once it has no remaining responsibility.

  4. Verify the containing workflow without the removed layer.


Anchor to Preserve these behaviorsPreserve these behaviors

  • Any user-visible behavior that was coupled to the removed component.
  • Behavior of remaining descendants, including focus, scrolling, overlays, or context where relevant.
  • Test setup and cleanup paths that referenced the removed layer.

Anchor to Test and remove Polaris ReactTest and remove Polaris React

Test the workflows that formerly depended on ScrollLock. Verify remaining descendants render correctly and that focus, scrolling, overlays, and test setup no longer rely on the removed layer.

Don't remove @shopify/polaris while another component still imports it. Once all call sites are migrated, remove the package and its provider-level setup, then run the app's full test suite.


Was this page helpful?