lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Should not focus on root element

Open aquarius-wing opened this issue 1 year ago • 2 comments

Lexical version:

Steps To Reproduce

  1. Open Playground
  2. Remove all text and type ``` and space key
  3. Type some text like 11111
  4. Press Arrow Up Key multiple times

https://github.com/facebook/lexical/assets/16633962/25e84327-c799-4e6a-a178-0455c8520f82

The current behavior

You'll notice that the selection switches back and forth between the text node and the root node

The expected behavior

Just focus the text node only

aquarius-wing avatar Apr 26 '24 09:04 aquarius-wing

Hi! Thanks for noticing this. IMO it actually shall stick to root and stay there. Why? How else can you insert something before that code block? :) Also cursor shall be placed before code block

StyleT avatar Apr 26 '24 14:04 StyleT

It's turely work when we want to add text before code block, but it doesn't clear to tell user "now we can insert text before code block!" when focus the root element. Because it seems exactly the same.

In my situation, my solution is when user pressing arrow up key, it will insert a paragraph before directly.

https://github.com/facebook/lexical/assets/16633962/f577fb46-cbef-4a32-a017-9307aa96c3ab

Speaking of which, why do I raise this question? It's to ensure that the focus can be correctly disengaged at the beginning of my editor (not the application shown in the video above).

Example

It's like we have a form, which has input , and a lexical editor, I want the user to be able to navigate between them by pressing the up arrow key.

However, the behavior differs when we focus on the code block, quote and offset is set to 0, it will make the code I write become complex, I believe this is an area that could be improved.

So I suggest, the selection can not be switch to the root element.

aquarius-wing avatar Apr 27 '24 02:04 aquarius-wing