Bug: Simple setup example returns error when you press an arrow (left or right)
Lexical version: Latest (simple setup live example on lexical.dev)
Steps To Reproduce
- Press right arrow in lexical simple setup example window
Tested on Edge, Chrome and Firefox.
Link to code example: https://lexical.dev/
The current behavior
TypeError
lexical.$getAdjacentNode is not a function
at Object.$shouldOverrideDefaultCharacterSelection (https://g932e.csb.app/node_modules/lexical/selection/LexicalSelection.dev.js:937:32
at Array.eval (https://g932e.csb.app/node_modules/lexical/plain-text/LexicalPlainText.dev.js:197:19
triggerCommandListeners
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:9551:29
eval
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:9530:19
beginUpdate
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:9685:5
updateEditor
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:9776:5
LexicalEditor.update
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:11522:5
triggerCommandListeners
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:9529:12
dispatchCommand
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:1398:10
onKeyDown
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:3206:5
HTMLDivElement.eval
https://g932e.csb.app/node_modules/lexical/Lexical.dev.js:3414:9
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.
This error overlay is powered by `react-error-overlay` used in `create-react-app`.
The expected behavior
No error
Same here, was playing with the simple demo from docs, and could not select text with shift + left/right. Basically, any arrow key breaks the app
@zurfyx @acywatson do we know who owns this sandbox, even though this seems like a bug, unsure if it's a deprecated API.
Yep, seems like outdated API in a sandbox https://codesandbox.io/s/lexical-plain-text-example-g932e?from-embed=&file=/package.json using lexicon 0.12.1.
When I forked the sandbox, changing the version to 0.12.2, it all works just fine
This was a dependency version mismatch in the CodeSandbox (g932e) — @lexical/selection imported $getAdjacentNode from lexical, but the lexical core package installed in the sandbox was a version that didn't yet export it. Not a bug in lexical itself.
The function call has since been replaced with the caret API ($caretFromPoint), and the embedded examples on lexical.dev have been updated. No longer reproducible on current versions.