ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.61k stars 3.23k forks source link

Keyboard select previous line unexpected behaviour #5068

Open kamnakis opened 2 years ago

kamnakis commented 2 years ago

Description

While using the keyboard (shift + arrows) to select text....

In chrome: If I try to move to a previous line (not wrapped text, 2 separate lines), even though the cursor is going on the previous line, the selection does not show. Instead it need another click to show (but selects last letter)

In safari: Similar but instead of not showing anything it shows a selection of a full line (that line does not exist)

Recording

Chrome

samyosm commented 2 years ago

After some research, this is a problem in most text-editor such as DraftJS, React Draft Wysiwyg or even Notion.so.

This also happens when doing the inverse: trying to select the bottom text using Shift + RightArrow.

kamnakis commented 2 years ago

After some research, this is a problem in most text-editor such as DraftJS, React Draft Wysiwyg or even Notion.so.

This also happens when doing the inverse: trying to select the bottom text using Shift + RightArrow.

Any ideas on what might be causing this?

dylans commented 2 years ago

Any ideas on what might be causing this?

Ambiguity on whether the user is at the end of one element or the start of the next and default browser behavior.

There's been some recent work on hanging ranges which fixed some things but regressed some other behavior, e.g. cursors moving up and down a list with voids in the list, if the void width is wider than the content of a list item.