"Reverse typing" effect in some instances where selection may have been lost #15182
Labels
domain:dx
This issue reports a developer experience problem or possible improvement.
domain:ui/ux
This issue reports a problem related to UI or UX.
package:engine
type:bug
This issue reports a buggy (incorrect) behavior.
Milestone
📝 Provide detailed reproduction steps (if any)
Hi, I'm building off of these bugs here, as the problem still persists:
For some background information, the original issue was first presented and solved in this bug:
This "reverse typing" effect unfortunately has many causes and manifestations which eventually lead to the same effect. The original bug #14569 had intended to solve the issue where selection was not updated in time due to heavy CPU usage while user was typing. This caused some reverse typing as the cursor would "stick" at the current selection, and not update.
This had been fixed with the PR: #14648 - #14648
This fix has worked quite well.
Now, we run into issues where if the editor is somehow taken out of focus in a "forceful" manner, typing will result in a reverse order due to the cursor never updating its position.
For example, one can synthetically reproduce this by running this piece of JavaScript code while the cursor is within the editor:
✔️ Expected result
Typing should never result in characters being visually placed in reverse order when the editor is not truly in focus.
❌ Actual result
Typing results in characters being injected in reversed order.
❓ Possible solution
To get around this, what we can do as integrators is actually listen in on the
beforeinput
event on theViewDocument
, at thelow
event priority. There's an interesting behavior that happens in this event, upon typing, if we manually dispatch a newFocusEvent
withfocus
to the editable, the selection is restored.For example:
Or building off our synthetic repro example as a demonstration:
Though this is a known workaround, for this specific scenario, I wonder what happens if some focus stealing of some other DOM element occurs, while the cursor is active in the inline editor will result in? For sure it's going to be reverse typing, but there are times where a specific JS library plays bad and maintains/traps focus no matter what.
The fact is that there is a cursor in the editable indicating that it is "focused" while it is not which is the tricky aspect to this all. I think if the editor truly does not have focus, it should not have a cursor. That's one scenario solved... maybe???? 🤔
📃 Other details
This happens in Chromium based browsers, Safari, etc.
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: