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

Fix long pressed accents on Chrome+macOS #3113

wants to merge 2 commits into from


Copy link

Calyhre commented Nov 13, 2019

Is this adding or improving a feature or fixing a bug?

Fixing a bug

What's the new behavior?

On macOS, long press triggers an IME to insert an accent. Browsers that implements beforeinput event uses the insertReplacementText and a proper range. Chrome is instead selecting the character to replace, right when the input is triggered.

Before After

How does this change work?

If we detect macOS && Chrome, the we proceed to check if the DOM selection has been updated before the input event and a detection of a selection change. The check is very naive but enough for this particular case. This can't happen when previous editor selection was expanded I guess.

I had to expose through a query the composition state of the before plugin, this is used to discard completely this fix in case of a user using another IME.

This issue was also fixed by #3041 but the fix is more trustworthy in my opinion, as we are not relying on any previous input.

I couldn't figured out how to test this with the current toolchain.

Have you checked that...?

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn prettier.)
  • The relevant examples still work. (Run examples with yarn watch.)

Does this fix any issues or need any specific reviewers?

Fixes: #982
Reviewers: @ianstormtaylor @knubie

@Calyhre Calyhre requested a review from ianstormtaylor Nov 13, 2019
@Calyhre Calyhre self-assigned this Nov 13, 2019
@Calyhre Calyhre changed the title fix(slate-react): Fix long pressed accents on Chrome+macOS Fix long pressed accents on Chrome+macOS Nov 13, 2019

This comment has been minimized.

Copy link
Collaborator Author

Calyhre commented Nov 14, 2019

⚠️ This does not work with composition 🙇‍♂️ Trying to find a better fix

Edit: Fixed

@ianstormtaylor ianstormtaylor mentioned this pull request Nov 14, 2019

This comment has been minimized.

Copy link

ianstormtaylor commented Nov 28, 2019

Fixed by #3093.

@Calyhre Calyhre deleted the fix/macos-chrome-longpress branch Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.