Skip to content

fix(menu): avoid focusing hidden anchors on mount - #5139

Merged
Doberjohn merged 2 commits into
callstack:mainfrom
KuroGeo:fix/menu-focus-on-hidden-mount
Oct 29, 2026
Merged

Doberjohn merged 2 commits into
callstack:mainfrom
KuroGeo:fix/menu-focus-on-hidden-mount

Conversation

@KuroGeo

@KuroGeo KuroGeo commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Closed menus steal focus on mount and scroll async lists. Initialize previous visibility from visible, preserving focus on open/close.

Related issue

Closes #4907

Screenshots / Videos

Append 30 closed menus: before, focus moves to Menu 29 and scroll reaches 1620px; after, focus stays on the append button and scroll stays at 0.

Before
After

Test plan

Append closed menus: focus/scroll stay put. Open: first item focuses. Escape: anchor focuses. Chrome checked.

695 tests and 234 snapshots pass; lint/typecheck pass. Hidden-mount regression fails before the fix.

Repro and DOM checks

Comment thread src/components/__tests__/Menu.test.tsx Outdated

@ziarno ziarno left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, added one comment with a nit

@Doberjohn Doberjohn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Verified on web in the example app: on main, loading the Menu screen moves focus to the last menu's anchor; with this fix focus stays put, opening a menu focuses its first item, and Esc returns focus to the anchor.

Good job!

@Doberjohn
Doberjohn merged commit 4dbf7d6 into callstack:main Oct 29, 2026
10 checks passed
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.

[Web] Menu anchor inside lists causes aggressive auto-scroll and focus hijacking on mount

3 participants