facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
19.7k stars 1.68k forks source link

Bug: BlockCursorElement inconsistent/unresponsive behavior #6822

Open madsone opened 1 day ago

madsone commented 1 day ago

Lexical version: 0.20.0

Steps To Reproduce

  1. Insert a table
  2. Put the table as the first element in the editor
  3. Use arrow-up so that the cursor is laying flat over the table
  4. Press down on the keyboard
  5. Do the same thing, but at the bottom of a table

Screenshot 2024-11-13 at 11 49 07 The screenshot show the inital state in order to reproduce the behavior

Link to code example: https://playground.lexical.dev/

The current behavior

When using a flat cursor and pressing the arrow down key from the top, the cursor correctly navigates to the first element in the table. However, the cursor is not visible and typing does not produce visible text. Additionally, it would be expected for the arrow down key to navigate within the table.

Sometimes it is possible to write in the first cell, but the cursor is not updated until one starts writing.

On the other hand, when starting from the bottom, the behavior works better. Pressing the left-arrow key will navigate to the bottom-right cell. However, it would make sense for the arrow up key to navigate back to the table.

The expected behavior

Mentioned above. Pressing the key up/down should make the cursor enter the table and show correctly where you are in the editor.

Impact of fix

This issue is a minor bug that primarily affects accessibility. While it is not causing an outage, it would be considered a "nice-to-have" improvement rather than a critical one.

The users who would most benefit from this fix are those who rely on keyboard navigation to use the editor. Currently, it is possible to work with, but implementing this upgrade would greatly improve the experience for keyboard users.

etrepum commented 22 hours ago

Are you trying this with the current playground, or v0.20? The current playground is always deployed from the latest main commit and has changes that affect both tables and the reconciler. The browser you're testing with is also relevant here, they all behave a bit differently in contentEditable especially with how keyboard navigation works. There is no standard.

madsone commented 8 hours ago

Sorry for the confusion. I was first going to show my local setup, but it seemed easier to use the playground since it produced the same behaviour.

Im using Google Chrome(130.0.6723.117) on the Lexical Playground.

etrepum commented 8 hours ago

I think this is a missing piece of the selection normalization that needs to happen with tables, it's certainly a bug either way.