Rich Text: Detect handled horizontal navigation by preventDefault #7644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'spreventDefault
to anoop
when the arrow key is moving away from the inline boundary (not within it). This allowsWritingFlow
to detect the key press as being handled via the standardEvent#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: