fix(editor): stabilize slash menu arrow key navigation (#205)#214
Conversation
- Split options useMemo into stable baseOptions (editor-only dep) and a separate filter memo, so MenuOption refs survive across query changes - Add explicit scrollIntoView on highlighted items within the scrollable menu container, bypassing Lexical's built-in scroll that targets the wrong element (#typeahead-menu anchor div vs overflow-y-auto menu) - Add E2E regression tests for sequential arrow navigation and scroll Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
✅ UI verification passed — design spec compliance confirmed. Static analysis: All classes in Visual verification: Playwright screenshots of the editor page (desktop dark + mobile) and slash command menu (open state + scrolled to bottom) confirm:
|
|
E2E suite: 49 passed, 2 failed, 3 skipped (due to dependency on failed test) This PR's new tests both passed:
Pre-existing failures (not caused by this PR):
Ad-hoc smoke tests: ✅ All passed
|
Closes #205
What
The slash command menu (
/) jumped back to the first item when navigating with arrow keys. Two issues caused this: (1) theoptionsarray was recreated viauseMemoon everyqueryStringchange, discarding theMenuOption.refDOM references that Lexical's internal arrow-key handler relies on for scroll-into-view, and (2) Lexical's built-inSCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMANDtargets the#typeahead-menuanchor positioning div rather than theoverflow-y-autoscrollable menu container we render, so items were never scrolled within the menu.How
Split the single
useMemointo a stablebaseOptionsmemo (depends only oneditor) and a separate filter memo (depends onbaseOptions+queryString). This keepsMenuOptioninstances and their DOM refs alive across query changes. Added explicitscrollIntoView({ block: 'nearest' })on the highlighted item viarequestAnimationFramein the render function, triggered whenselectedIndexchanges, targeting children of our scrollable menu container directly.Testing
pnpm lint && pnpm typecheck && pnpm testall pass.