-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Enable Command Palette in admin dashboard #71030
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
Conversation
a5b8dab to
668314a
Compare
|
Size Change: +200 B (+0.01%) Total Size: 1.92 MB
ℹ️ View Unchanged
|
0d56922 to
aa92e59
Compare
aa92e59 to
b2ecac7
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| if ( in_array( $pagenow, array( 'site-editor.php', 'post.php', 'post-new.php' ), true ) && $current_screen->is_block_editor() ) { | ||
| return; | ||
| } |
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 early return is necessary to avoid conflicts with the Command Palette UI in the post editor and site editor. For example:
| <CommandMenu /> |
However, if we can stabilize the "Command Palette everywhere" in the future, we may be able to remove the dependency on the core-commands package from the post editor and site editor packages and consolidate the core Command Palette functionality into initializeCommandPalette().
| useAdminNavigationCommands(); | ||
| useSiteEditorNavigationCommands(); | ||
| return ( | ||
| <RouterProvider pathArg="p"> |
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.
Some core commands use the useHistory hook. This routerProvider is required for these commands to work correctly.
|
|
||
| // The Site Editor and Post Editor already implement the Command Palette | ||
| // within the app, so do nothing on those pages. | ||
| if ( in_array( $pagenow, array( 'site-editor.php', 'post.php', 'post-new.php' ), true ) && $current_screen->is_block_editor() ) { |
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.
Should we remove it from the editors and avoid this check?
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 think it can be removed at the moment. See #71030 (comment) for the reason.
We can remove it if we don't use experimental settings, but personally I'd like to iterate a bit more before stabilizing.
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.
Do you think we can follow-up with this?
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 explanation wasn't clear enough.
If we remove this check, we'll need to remove the command in the edit-post and edit-site to prevent duplicate registration of the command.
However, removing the command from these two packages will mean that the command won't work when the two packages are bundled into core.
However, if we can decide to ship this PR into WP 6.9, we can remove this check along with the core backport PR.
I hope I explained it well 😅
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.
However, removing the command from these two packages will mean that the command won't work when the two packages are bundled into core.
I don't understand this part, I expect the backport of the new global command and the edit-post edit-site changes to happen at the same time. (6.9)
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 expect the backport of the new global command and the edit-post edit-site changes to happen at the same time. (6.9)
That's right. However, since we need to do the PHP backport and package updates at the same time, we need to do that right before WP 6.9 Beta 1, right?
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.
Nothing is stopping us from doing multiple package updates no?
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 kind of issue of having to do php changes and package update at the same time is not new and not specific to this case. I'm not sure it's something we should be thinking about when shipping things to the Gutenberg repo. For me it's a workflow issue.
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 see, I think I might be misunderstanding 😅 I'd like to submit a follow-up PR to remove this check soon.
| * Initializes the Command Palette. This function does nothing | ||
| * unless the experimental setting is enabled. | ||
| */ | ||
| export function initializeCommandPalette() { |
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'm hesitant about whether this should leave in this package or if we should have a edit-command package or something like that. I'm not sure yet.
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 agree. If the direction of the Command Palette becomes clearer, we may be able to change to a more appropriate approach.
youknowriad
left a comment
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 is a great start, I'd be fine not having an experiment to get more feedback before Core release.
|
Thanks for tackling this! |
Co-authored-by: Shail Mehta <shailmehta25@gmail.com>
youknowriad
left a comment
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.
Let's try to land this. Personally I'd still argue that it shouldn't be an experiment though and it should just be enabled by default with the Gutenberg plugin to get as much testing as possible.
I see, I've removed the experimental setting in 3e9ff1e. |
| if ( ! globalThis.IS_GUTENBERG_PLUGIN ) { | ||
| return; | ||
| } |
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 prevents unintentional execution of initializeCommandPalette when the core-commands package is bundled with core.
) * Experimental: Enable Command Palette in admin dashboard * Update lib/experimental/commands.php Co-authored-by: Shail Mehta <shailmehta25@gmail.com> * Remove experimental setting * Update docs --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: shail-mehta <shailu25@git.wordpress.org> Co-authored-by: mtias <matveb@git.wordpress.org>
|
@t-hamano I slightly edited the PR description to make it clear that this doesn't need experiment enabled first like you had initially planned; hope you don't mind! |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
What?
This PR includes a minimal implementation and first iteration to move #58218 forward.
As a first step, enable the Command Palette in the admin dashboard
as an experimental feature(ref).Why?
See #66648
One of our goals for WordPress 6.9 is to make the Command Palette available everywhere. We need to provide a working UI as soon as possible, so we can gather as much feedback as possible and iterate further.
How?
initializeCommandPalette()to render the component. This function has to be public, but it does nothing if the experimental settings are not enabled. This prevents unintended use as much as possible.Testing Instructions
Screenshot