facebook / lexical

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

Add setTimeout for mousemove handler #5919

Closed AlexanderReznik closed 1 week ago

AlexanderReznik commented 1 week ago

Fixes table-selection-scroll Selection is getting stuck and the page is not getting scrolled automatically

Happens in Chrome, not in Firefox The problem is that the order of events mousemove and selectionchange is not deterministic. When mousemove is handled before it prevents selectionchange handler from executing fully resulting in this bug.

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2024 10:37am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2024 10:37am
StyleT commented 1 week ago

Hi! Thanks for the PR! Do you think it's possible to add test here to prevent future regression?

AlexanderReznik commented 1 week ago

Do you think it's possible to add test here to prevent future regression?

I've tried, couldn't add a test for the mouse leaving the window to cause a scroll

StyleT commented 1 week ago

Do you think it's possible to add test here to prevent future regression?

I've tried, couldn't add a test for the mouse leaving the window to cause a scroll

No worries, can you pls then add a code comment to explain setTimeout presence and TODO with newly created issue number that shall address lack of test here. So someone else (maybe me), can take a look at the test.

I'll merge it right after you have comment + follow up issue to write test.

AlexanderReznik commented 1 week ago

No worries, can you pls then add a code comment to explain setTimeout presence and TODO with newly created issue number that shall address lack of test here. So someone else (maybe me), can take a look at the test.

https://github.com/facebook/lexical/issues/5928 https://github.com/facebook/lexical/pull/5919/commits/c626b1b8cbeb7daa1a42d474881c4fc790bdd6c1