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

Rich Text: Detect handled horizontal navigation by preventDefault #7644

Merged
merged 1 commit into from
Jul 2, 2018

Conversation

aduth
Copy link
Member

@aduth aduth commented Jun 29, 2018

Related: #6712

This pull request seeks to improve upon the implementation of horizontal navigation in RichText from #6712. Per observation in #6712 (comment) , it finds a workaround to TinyMCE's calling of preventDefault on an unhandled caret movement by reassigning its internal event's preventDefault to a noop when the arrow key is moving away from the inline boundary (not within it). This allows WritingFlow to detect the key press as being handled via the standard Event#defaultPrevented, rather than knowledge of an internal _navigationHandled property.

Further, it avoids binding a keydown event to the entire document, which as noted in #6712 (comment) could be problematic.

The revised implementation also seems to correct a potentially wrong behavior where collapsing a selection was wrongly causing the selection to be moved to a previous / next paragraph. This is reflected in updated end-to-end test with explaining comment.

Testing instructions:

Verify that you can traverse into and out of inline boundaries, including those which occur at the beginning or end of a paragraph.

Ensure end-to-end tests pass:

./bin/run-e2e-tests.sh

@aduth aduth added the [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable label Jun 29, 2018
@aduth aduth requested a review from tofumatt June 29, 2018 20:08
Copy link
Member

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

This is so much nicer! The code is easier to understand. Everything still works great for me.

I noticed the splitting of bold text with return seems to work better too–it moved focus to the correct paragraph.

I can't run the e2e tests right now and feel bad blocking this on that.

@aduth
Copy link
Member Author

aduth commented Jul 2, 2018

I noticed the splitting of bold text with return seems to work better too–it moved focus to the correct paragraph.

Nice incidental win 😄 Same issue was also intended to be improved with #7620 .

@aduth aduth merged commit 66f2d2a into master Jul 2, 2018
@aduth aduth deleted the fix/inline-boundary-zwsp branch July 2, 2018 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants