Skip to content

Prevents selection after ZWSP character#1552

Merged
koke merged 4 commits intodevelopfrom
fix/1530-lowercase-keyboard
Nov 8, 2019
Merged

Prevents selection after ZWSP character#1552
koke merged 4 commits intodevelopfrom
fix/1530-lowercase-keyboard

Conversation

@koke
Copy link
Copy Markdown
Member

@koke koke commented Nov 6, 2019

The original issue was that when tapping on an empty RichText, the selection was going to the end of the text by default. As we use the ZWSP character as a placeholder, the selection was after that character, and the keyboard appeared in lowercase mode.

I have a fix that corrects this, but I'm not 100% sure if this is the best place to fix it.

Fixes #1530

To test:

Some scenarios to reproduce the issue:

  • Insert a media-text block and tap on the empty paragraph
  • On a blank new post, tap on the placeholder, then tap again
  • On a blank new post, dismiss the keyboard, then tap on the post title

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

// MARK: - Selection
private func correctSelectionAfterZWSP() {
guard selectedTextRange?.start == endOfDocument,
text == String(.zeroWidthSpace) else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think we could associate the check with this configuration in common init: https://github.com/wordpress-mobile/gutenberg-mobile/pull/1552/files#diff-ad68d1bf3bf68556db4be6e6215573adL136

Just in case the character changes in the future?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, pushed a change to make it more generic

@koke koke requested a review from SergioEstevao November 8, 2019 11:25
Copy link
Copy Markdown
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Media & Text keyboard is set to lowercase

2 participants