-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Editor: Add KeybindScope complement to NavigableToolbar #10699
Conversation
@@ -104,7 +99,7 @@ describe( 'Demo content post', () => { | |||
// Create the aligned right paragraph | |||
await page.keyboard.press( 'Enter' ); | |||
await page.keyboard.type( '... like this one, which is right aligned.' ); | |||
await moveMouse(); // This shouldn't be necessary to show the toolbar | |||
await page.keyboard.press( 'Escape' ); |
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.
My ideal solution would be to avoid this entirely and "show" the toolbar when alt + f10
is hit. I don't know if that's possible though.
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'd agree, and see this more as an interim step in the right direction (i.e. at least making it possible by keyboard-only). I'd put some thought toward what would be required to focus the non-visible contextual toolbar and I think it'll require some non-trivial state/lifecycle wizardry in BlockListBlock to have it be forced visible / focused.
Roughly, I imagine it looking like:
NavigableToolbar.KeybindScope
has aonShortcutPressed
callbackBlockContextualToolbar
/BlockToolbar
accepts anautoFocus
prop which behaves similarly to the equivalently-named input attributeBlockListBlock
assigns a callback for this which somehow incurs a new render which triggers consideration inshouldShowContextualToolbar
to force it to be shown, and somehow assigns theautoFocus
prop.
I'd like to reserve this for a subsequent pull request.
Question: what happens when you tab into the toolbar (you didn't access it using |
As implemented, the relationship is not two-way except in tracking the element from which focus had transitioned when Alt+F10 was pressed, so it's not very compatible with this suggestion. I guess this depends whether we consider this more a transient state of shifted focus, or a strict relationship exists between two elements. For something like the header toolbar, is there a singular element it's expected to return to when Escape is pressed? The more I think on it, the more I think the answer is "no". |
I've been thinking about this lately too, I was trying to think what would be an alternative and I came up with this. Let me know what you think:
I'm mostly trying to think how I'd approach it to make it as simple as possible but now that I'm writing this, it does feel a bit complex too. Anyway, I'll plan to dive deeper into this PR to understand your proposal better. Edit: I wonder if |
Importantly, this supports more than just a block toolbar, but also considers:
|
To simplify this some, I extracted |
69f6545
to
6be549c
Compare
Okay, I think this one should be ready for a proper review. I'd like to have authored the end-to-end tests to verify the behavior in an inline toolbar, but between embeds mocking and potential for focus loss in embeds, I'm feeling blocked at the moment. I can create a follow-up issue for it, if it's acceptable to let the current included tests serve as a basis. |
4e8f092
to
24f8046
Compare
#11237 messed with this one a fair bit. I had to undo the addition there of focusing the wrapper. The alternative would be to move the However, there is a bug which remains, affecting both this branch and master, which is the behavior of "Escape" in clearing the selected block. This has some strange effects in causing an error and the selection to remain in first multi-selected block (if applicable, e.g. paragraphs) but no longer technically being selected (proceeding to press Shift+ArrowDown does nothing). I think we'll need to have a more durable handling of the propagation of the Escape press between the block toolbar, multi-selection, and top-level block selection clearing. |
I can't speak to the code but just want to observe that, as depicted in the screen capture, it feels strange that |
@chrisvanpatten Maybe true. The concern of the pull request is to normalize current behaviors though of contextual toolbars. |
This PR needs to be refreshed. It's over 3 months old so I'm marking as |
Would it be possible to give this some higher priority please? The JS error still happens in Safari and IE11. The Escape key moving focus back from the toolbar to the editable area is standard interaction in TinyMCE and it's the behavior users expect. |
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.
This sounded like a sensible approach. Would need some refresh 🙂
I'm hoping to set aside time this week to refresh this. |
24f8046
to
ffceb30
Compare
I've force-pushed a refreshed branch. Most all remains the same as before. There were a few updates needed to accommodate @jorgefilipecosta 's work in #11607. I also (hopefully) improved the behavior with tracking focus leaving a toolbar as the result of Escape press vs. other user interaction, which previously had some room for error. It works fairly well for me, though it's still not quite fully polished:
|
Triaging PRs today. I feel there's still a need for this PR but with all the changes that happened, we may want to just close it and revisit it when we have more time? Thoughts @aduth |
To me, it seems like we would want something like in the original approach of stepping and and down the ancestry of toolbars (or some way to avoid an ancestry altogether). However, going through the history of this pull request and the associated issue #6165, it's not entirely clear to me if the main problem was more the error, which apparently was "resolved" in some form or another by the navigation mode. All being said: Yes, it's too far out of date at this point to hope to rebase it. The fact that navigation mode now occupies the Escape keybind introduces some additional challenges here. It would be good to track whatever effort (if any) we want to follow-up on here. I don't feel entirely confident in writing this, since at this point I don't know exactly how that should be implemented. In any case, let's close this one out for the time being. |
Supersedes #10529
Fixes #6165
This pull request seeks to revise the behavior of
NavigableToolbar
from implementing a global keybind to instead observe key combinations within a specific scope. Further, in restoring focus after an Escape press from the toolbar, it considers the element which had focus before focus had shifted to the toolbar programmatically. The scoping also allows for "stepping" behavior, where Alt+F10/Escape respectively work their way up/down to/from the nearest navigable toolbar scope.Implementation notes:
Remaining tasks:
Testing instructions
Verify that, with toolbars present, Alt+F10 sequentially steps upward to the "closest" toolbar. Conversely, Escape steps back down.