lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Simple setup example returns error when you press an arrow (left or right)

Open atiris opened this issue 3 years ago • 4 comments

Lexical version: Latest (simple setup live example on lexical.dev)

Steps To Reproduce

  1. 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

atiris avatar Sep 25 '23 18:09 atiris

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

image

davidfrtala avatar Nov 06 '23 20:11 davidfrtala

@zurfyx @acywatson do we know who owns this sandbox, even though this seems like a bug, unsure if it's a deprecated API.

ivailop7 avatar Nov 07 '23 09:11 ivailop7

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

davidfrtala avatar Nov 13 '23 20:11 davidfrtala

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.

mayrang avatar Jul 15 '26 11:07 mayrang