RichText: ignore selection changes during composition #16960
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes input composition after #16875. We're checking selection during
keyup
now as well, but we shouldn't do that during input composition as the browser will otherwise fail to compose.This is done already for the
selectionchange
event:gutenberg/packages/rich-text/src/component/index.js
Lines 327 to 331 in 005e030
Unfortunately I'm not able to write any e2e tests. Puppeteer won't compose characters when given the right sequence of keys, and I'm not succeeding at emulating it. I cannot recreate the internal state and UI that the browser has, and it's this state that gets destroyed if we record any input or selection during composition.
The line under this backtick means that the browser is composing. Any ideas are welcome here.
How has this been tested?
This depends a bit on your keyboard layout. For a US/QWERTY layout:
Alt+`
.a
.The result should be
à
.(Puppeteer ignores
Alt+`
here.)Screenshots
Types of changes
Checklist: