Skip to content

fix(overlays,keystatic): lock background scroll for component menus (#1634) - #1685

Open
MilindChatrabhuji wants to merge 2 commits into
Thinkmill:mainfrom
MilindChatrabhuji:fix/component-menu-scroll-lock-1634
Open

MilindChatrabhuji wants to merge 2 commits into
Thinkmill:mainfrom
MilindChatrabhuji:fix/component-menu-scroll-lock-1634

Conversation

@MilindChatrabhuji

Copy link
Copy Markdown
Contributor

Fixes #1634

Summary

When inserting components or opening a component-selection dropdown in a scrolled entry form (BlocksFieldInput, DocumentEditor / insert menu, or Markdoc / autocomplete menu), mouse wheel and single-finger touch scroll events could scroll the underlying page ScrollView behind the open menu.

Changes

  • @keystar/ui (design-system/pkg/src/overlays/scrollLock.tsx, overlays/index.ts): Added usePreventBackgroundScroll and using capture-phase wheel, ouchstart, and ouchmove listeners scoped to the topmost active overlay container (supporting multi-touch zoom passthrough, RTL horizontal scroll metrics, and nested overlays) without mutating document.documentElement.style.overflow or stealing focus.
  • @keystar/ui overlays & lists (Blanket.tsx, ListBoxBase.tsx, ComboboxMulti.tsx):
    • Wired usePreventBackgroundScroll into Blanket (covering Popover, Modal, Tray, MenuTrigger, Picker, and BlocksFieldInput add-block / insert-block menus) along with overscrollBehavior: 'none' and ouchAction: 'none'.
    • Wired usePreventBackgroundScroll into ComboboxMulti and added overscrollBehavior: 'contain' on ListBoxBase's .
  • @keystatic/core editor menus (DocumentEditor/insert-menu.tsx, markdoc/editor/autocomplete/autocomplete.tsx):
    • Updated DocumentEditor insert-menu overflow to overflowY: 'auto' with overscrollBehavior: 'contain' and attached while open.
    • Wrapped the Markdoc / autocomplete listbox inside (since its EditorPopover renders inline with portal={false}).
  • Tests & Changeset: Added unit and integration tests in design-system/pkg/src/overlays/test/scrollLock.test.tsx and packages/keystatic/src/form/fields/markdoc/editor/tests/insert-menu-scroll-lock.test.tsx, plus a patch changeset for @keystar/ui and @keystatic/core.

Verification

  • Formatting, lint, types, and package build (prettier --check, eslint, sc --noEmit, preconstruct build, preconstruct validate): all passed after final edits.
  • Targeted Vitest suites (overlays/test, menu/test, combobox/test, picker/test, insert-menu.test.tsx, insert-menu-scroll-lock.test.tsx): 11 test files passed (152 passed, 2 pre-existing skipped).
  • Isolated re-run of code-block.test.tsx: passed (14 passed, 2 skipped). Full Windows workspace run passed 144/151 files (1,244 tests) with unrelated local Windows symlink EPERM (
    ead-local.test.ts) and pre-existing Toast/
    outer/DropZone test setup failures.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 504122a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@keystar/ui Patch
@keystatic/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Component-selection dropdown/popover doesn't lock background scroll while open

1 participant