-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Writing Flow: Consider horizontal handled by stopPropagation in RichText #6712
Conversation
I'm taking a look at this and fixing the merge conflict, so I'll be pushing a rebased branch in a bit. |
2512df9
to
9eddb36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editor/components/rich-text/index.js
Outdated
|
||
// [WORKAROUND]: When in a new paragraph in a new inline boundary node, | ||
// while typing the zero-width space occurs as the first child instead | ||
// of at the end of the inline boundary where the caret is. This should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite follow the sentence "This should only be exempt when focusNode is not only the ZWSP, which occurs when caret is placed on the right outside edge of inline boundary."
Could you rephrase it to explain what this is saying? I don't quite follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I was reading this again earlier and was having a hard time following my own explanation, so yes, I definitely agree it could do for some rephrasing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside: Created issue for this in TinyMCE at tinymce/tinymce#4472
Thanks for the review and updates @tofumatt . I'm not sure I agree with moving the ZWSP constant to the keycodes module, for two reasons:
That said, this sadly isn't the only occasion where we reference the value, so I can certainly appreciate the desire to have a single source of truth for it. Internally, TinyMCE does expose some utilities, though in scouring their public API I don't think it is made available for us to consume. Alas, my intuition is to move this back into Thoughts? In the meantime, I also want to add a simple end-to-end test here. I should be able to salvage something from #6467. |
Oh, fair enough on it not really being a keycode. |
Updates:
My only remaining hesitation is a reluctance against stopping propagation. For example, this could inadvertently prevent
|
From what you've written here, the second option sounds less complex and easier to implement. I'd be curious to see how "unnatural" the delay in changing paragraphs was–maybe it's not so bad? Or maybe it's quite bad and not worth pursuing. 🤷♂️ |
I was so very close to an amazingly simple solution, which would be to rely on TinyMCE preventing the default on the event when it's handled internally, which could be inspected from However, this seems to not work in all cases, namely at the outside edge of an inline boundary, where it falsely reports as handling an ArrowRight. Reported issue at tinymce/tinymce#4476. |
In retrospect though, I like the idea of using |
Ultimately I landed at a solution which is like the first idea in #6712 (comment) , and with full expectation that eventually we could drop all of this and rely on |
Oof, I forgot to account for the fact that |
Extracted from #6467
Fixes #5095
This pull request seeks to stop propagation of horizontal arrow key down events when it's inferred that this is to be handled by TinyMCE in traversing out of an inline boundary. This avoids an issue where TinyMCE moves the caret, then the WritingFlow proceeds to consider the arrow navigation, leading to it being impossible to arrow-navigate out of an inline boundary at the end of a paragraph (since TinyMCE moves the caret out, then WritingFlow moves the caret to the next block).
Testing instructions:
Repeat steps to reproduce from #5095, noting that you can escape out of the italicized text by pressing ArrowRight at the end of the paragraph.