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

Android mentions fixes #5360

Merged
merged 2 commits into from
Mar 16, 2023
Merged

Conversation

aciccarello
Copy link
Contributor

@aciccarello aciccarello commented Mar 14, 2023

Description
This fixes the Android keyboard handling of mentions by moving the non visible space character after the mention. This PR also adds a click handler to the mention dropdown to make it easier to test on mobile.

Issue
Solves the issue where typing immediately after a mention on Android causes the text of the mention to be repeated.

Example

As tested on Chrome on a Pixel 5A.

Before:

screen-20230314-192518_2.mp4

After:

screen-20230314-192843_3.mp4

Note that an issue with a period before a mention still persists.

Context
The non-visible spacer is important for focus and mention styling. There are a lot of issues related to this character including possibly changing from the current \uFEFF character, but those changes should be orthogonal to this issue.

The reason this solution works is because the Android keyboard works with whole words rather than simply inputting one character at a time. This triggers before input events that compose multiple characters together. However in the case of void elements, the keyboard sees the text before the cursor and tries to include that in the autocomplete. When slate goes to enter the text, it assumes the text is entirely new and adds it on top of the existing text.

Closes #5357

Related Issues and PRs

Checks

  • 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 fix.)
  • The relevant examples still work. (Run examples with yarn start.)
  • You've added a changeset if changing functionality. (Add one with yarn changeset add.)

Android keyboards use a composition text approach for autocomplete purposes.
Chrome sees the mention text and thinks it is part of the word to complete.
The simplest solution is to add zero width whitespace.

This also adds a click handler on the mention example to help
with the mobile (and desktop) testing experience.
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2023

⚠️ No Changeset found

Latest commit: aca1e4c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@aciccarello aciccarello marked this pull request as ready for review March 15, 2023 16:44
@aciccarello
Copy link
Contributor Author

This is ready for review. No changeset was added as the change is only to an example.

@dylans dylans merged commit e587880 into ianstormtaylor:main Mar 16, 2023
@aciccarello aciccarello deleted the android-mentions-fixes branch March 16, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mentions cause deletion issues on Android
3 participants