-
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
Block editor: use React events for shortcuts (portal bubbles & contextual) #32323
Conversation
Size Change: +10 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
15ac136
to
4c1f6c5
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.
I tested this and it works in an identical way for the user. I think the reasons for the change in the PR's description are very good.
Unfortunately in Safari the shortcuts are picked up by the browser even in editor context (e.g. cmd + D opens the bookmark dialog, cmd option shift t opens the profiling in Inspector). |
8f3c243
to
ecdea3f
Compare
652df47
to
7636e79
Compare
7636e79
to
2d6754a
Compare
This is a big departure in terms of APIs for the shortcuts package, I think it'd have deserved more eyes a bit. For instance
I don't think that makes sense for all shortcuts, some of the shortcuts are I also kind of like the |
@@ -192,66 +192,65 @@ export default function VisualEditor( { styles } ) { | |||
}, [ isTemplateMode, themeSupportsLayout, contentSize, wideSize ] ); | |||
|
|||
return ( | |||
<div | |||
<BlockTools |
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.
For me if this needs to be a parent of the block editor, it needs to be documented properly in the block-editor package and the documentation we have to build third-party block editors.
That said, the naming is not great at all, shouldn't be BlockEditorWrapper
or something like that? Also, if it's a wrapper, why not just bundle it in BlockEditorProvider
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.
Why does it need to be higher up the tree? Agreed on the documentation, I should add some.
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 understand the question. My main motivation here is that it seems we're requiring two wrappers where we can require just one. Unless I'm not understanding properly both these components should wrap the editor canvas? Maybe more granularity is needed, but it's not clear from the user's perspective where to put each one of these components.
Description
Builds on #32318.
Moves shortcut handlers from native events to React events for two reasons:
document
). This is important because you may have other things on the page beside the block editor, or multiple block editors. Shortcuts should only work if focus is within a certain context. Using React evens works nicely because they bubble both through the iframe and other portals such as the inspector.Lastly, it removes some boilerplate for implementing a block editor, building
<BlockEditorKeyboardShortcuts />
into<BlockTools />
.How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).