Bug: [TypeaheadMenuPlugin] Unexpected selectedIndex Jump to List Item Cursor is On When Navigating with Keydown/KeyUp #4296
Description
The selectedIndex in the TypeaheadMenuPlugin unexpectedly jumps to the list item that the mouse cursor is currently on when scrolling down the menu using the keydown/keyup navigation. This behavior occurs because the list items are listening for the onMouseEnter event, which updates the selectedIndex.
I am wondering if the onMouseEnter event is necessary. If it is not required, we could consider removing it to resolve this issue.
Lexical version: v0.9.1
Steps To Reproduce
- Visit the playground.
- Enter
/
. (This will open the Typeahead Menu.) - Hover over one of the list items.
- Press the down key until the menu scrolls down.
Lexical.Playground.-.Google.Chrome.2023-04-10.16-53-28.mp4
The current behavior
In the TypeaheadMenuPlugin, while navigating the menu using the up and down arrow keys, the selectedIndex unexpectedly moves to the list item where the cursor is currently located.
The expected behavior
When using the up and down arrow keys to navigate the menu, the selectedIndex should not unexpectedly move to the list item where the cursor is located. Instead, it should progress sequentially through the list items as intended.