Skip to content
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: ignore selection changes during composition #16960

Merged
merged 1 commit into from
Aug 14, 2019

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Aug 8, 2019

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:

if ( event && event.nativeEvent.isComposing ) {
// Also don't update any selection.
document.removeEventListener( 'selectionchange', this.onSelectionChange );
return;
}

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.

Screenshot 2019-08-08 at 11 51 01

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:

  • Press Alt+`.
  • Press a.

The result should be à.

(Puppeteer ignores Alt+` here.)

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@ellatrix ellatrix added the [Package] Rich text /packages/rich-text label Aug 8, 2019
@ellatrix ellatrix added this to the Gutenberg 6.3 milestone Aug 8, 2019
@ellatrix ellatrix force-pushed the fix/rich-text-composition branch from 22ecd61 to 40c6753 Compare August 9, 2019 10:14
@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release [Release] Do Not Punt Used to indicate the issue or pull request must not be moved from the assigned milestone labels Aug 9, 2019
@ellatrix ellatrix force-pushed the fix/rich-text-composition branch from 40c6753 to 2587972 Compare August 14, 2019 12:11
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ellatrix ellatrix force-pushed the fix/rich-text-composition branch from edf5956 to 2587972 Compare August 14, 2019 12:49
@ellatrix
Copy link
Member Author

Thanks for testing!

@ellatrix ellatrix merged commit b99ae56 into master Aug 14, 2019
@ellatrix ellatrix deleted the fix/rich-text-composition branch August 14, 2019 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Rich text /packages/rich-text [Release] Do Not Punt Used to indicate the issue or pull request must not be moved from the assigned milestone [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants