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
RichText: fix isComposing for Safari #19171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for the prompt fix!
document.removeEventListener( 'selectionchange', this.onSelectionChange ); | ||
// Do not trigger a change if characters are being composed. Browsers | ||
// will usually emit a final `input` event when the characters are | ||
// composed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the comments. Maybe expand this one to reflect the current change, e.g.
… As of December 2019, Safari doesn't honour
nativeEvent.isComposing
.
Incidentally, that could make it easier — later on, in a year or ten — to know what workarounds can be eliminated in our code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I should add something here. I'm also wondering if I should still use nativeEvent.isComposing
and fall back to this.isComposing
. Normally compositionstop
should fire, but who knows, if in some rare cases it doesn't, the value would be stuck at true
until composing is started again. nativeEvent.isComposing
is probably more reliable. On the other hand, always using this.isComposing
will more quickly surface any bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't oppose to listening to those two sources, but is there anything making you doubt of compositionstop
's reliability? Since it's a proper SyntheticEvent
, I would expect adequate browser support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, browser support is good, but I wouldn't be surprised if it's implemented slightly differently in browsers, just like the calling order of all these event handlers, or not called at all in some situations. Let's try this and keep an eye on reports.
Description
Fixes #19161.
Apparently Safari doesn't support
isComposing
on aninput
event. See https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/isComposing.The solution is to set a flag on
compositionstart
and remove andcompositionend
.Unfortunately, we cannot add an e2e test right now. See puppeteer/puppeteer#4981.
How has this been tested?
For an American keyboard:
Cmd+B
, thenAlt+`
, then type "a". "à" should be bold.Screenshots
Types of changes
Bug fix
Checklist: