-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug: LexicalMenu reads option.ref when options[newSelectedIndex] is undefined #7897
Copy link
Copy link
Closed
Labels
good first issueGood for newcomersGood for newcomersplaygroundpopoverIssues related to popover/menu code in the playgroundIssues related to popover/menu code in the playground
Description
Lexical version: v0.36.2+dev.esm (Playground)
Steps To Reproduce
- Open the Lexical Playground
- Enable mentions (@) and type the first letter to open the suggestion list.
- Move the cursor to the last entry (Arrow Down).
- Keep typing quickly so the list refreshes and shrinks before
selectedIndexis reset. You can try with 'pooja'. - Quickly press Arrow Down again
Or for a better success rate at reproducing it, have Hammerspoon doing it:
hs.hotkey.bind({"ctrl", "alt"}, "p", function()
hs.eventtap.keyStrokes("@")
hs.eventtap.keyStrokes("p")
hs.eventtap.keyStroke({}, "down")
hs.eventtap.keyStroke({}, "down")
hs.eventtap.keyStroke({}, "down")
hs.eventtap.keyStroke({}, "down")
hs.timer.usleep(1000000)
hs.eventtap.keyStrokes("ooj")
hs.eventtap.keyStroke({}, "down")
end)
The current behavior
If I'm not mistaken, this is happening here:
| if (option.ref != null && option.ref.current) { |
The expected behavior
The highlighted index should reset (or short-circuit) when the list shrinks so we never dereference a missing option.
Impact of fix
Prevents a crash under fast typing in typeahead/mentions flows used by any app relying on LexicalTypeaheadMenuPlugin
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersplaygroundpopoverIssues related to popover/menu code in the playgroundIssues related to popover/menu code in the playground
