[lexical-selection] Bug Fix: Correct backward inversion for RTL#7686
[lexical-selection] Bug Fix: Correct backward inversion for RTL#7686etrepum merged 3 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
As can be seen in the "After" video, exiting the decorator nodes should probably be inverted in some cases as well. However this is more tricky, as it's probably possible that before+after aren't the same direction, in which case it's unknown what should occur. In any case, I think when before+after are both RTL it's expected that a right arrow from the decorator node will move to the previous node instead of the next one and the left arrow will move to the next node, where I think changes can be made to the lexical-rich-text/src/index.ts file in the appropriate command registrations. I will probably open an issue (and hopefully PR) for this after #7685 is resolved. |
etrepum
left a comment
There was a problem hiding this comment.
This looks like a reasonable approach, although it would be fantastic to add an e2e test to show that it does what it's supposed to. Should be fairly straightforward since this is reproducible without adding anything to the playground, there are other tests in packages/lexical-playground/__tests__/e2e/Selection.spec.mjs (but nothing that tests rtl behavior yet)
|
I added a test case for this (and verified it fails before adding the change). |
|
It’s likely that move line to end/beginning has the same class of issue with rtl that needs a different workaround. The e2e test helpers tend to use input rather than some back door to force a specific state. It does look like these tests are failing, maybe only on some specific browser/platform combinations. |
|
Looks like plain text and collab should be disabled for this test. |
|
I think this is still broken when its in the end of the paragraph for instance. Investigating now. |
Description
This updates the
$shouldOverrideDefaultCharacterSelectionto the correct "backward" value when inside an RTL element.Closes #7685.
Test plan
Before
Screen.Recording.2025-07-11.at.0.20.34.mov
After
Screen.Recording.2025-07-11.at.0.28.17.mov