-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IME] Strange selection behaviour when writing before a mark #2958
Comments
I investigated the bug, and it seem to come from the When typing into the editor, android write the text into the That element contains Array.from(zeroWidths).forEach(function (el) {
el.parentNode.removeChild(el);
}); The entered text is discarded and the offset is set to Later in the code, I see: // COMPAT: If the parent node is a Slate zero-width space, this is because the
// text node should have no characters. However, during IME composition the
// ASCII characters will be prepended to the zero-width space, so subtract 1
// from the offset to account for the zero-width space character.
if (offset === node.textContent.length && parentNode.hasAttribute(DATA_ATTRS.ZERO_WIDTH)) {
offset--;
} But with the logic above, I don't see how that can be executed, since a zero width is contained in a span with no attribute, then contained in a slate leaf element. |
With further investigations, I saw that normalization also set the offset to The node returned by I think the issue is because the text is entered in the wrong element inside the document. It should not write into the zero width node. Anyway, I refer this issue: #2368 since it only happen in android. I'm willing to give more information if necessary. |
I believe that this may be fixed by #3093, which has changed a lot of the logic in Slate and |
Do you want to request a feature or report a bug?
Bug
What's the current behavior?
The selection is moving at the start of the inputted text/letter when writing just before a mark. It only happen on Adroid.
I tested with Chrome android and chrome keyboard.
Here's a gif:
https://imgur.com/a/MfqlnfD
Code sandbox link
With a minimal slatejs setup, we were also able to reproduce the issue.
Due to how our app is made, a mark is almost always at the end so it happens all the time, crippling text writing.
What's the expected behavior?
The selection should be stable when writing
The text was updated successfully, but these errors were encountered: