-
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
Command Palette: Proper handling of page/post links in all themes #53718
Conversation
Size Change: +20 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
d05f4ee
to
a294e1d
Compare
a294e1d
to
a51f111
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.
Thank you! This LGTM!
Not related to this PR, when I tested with WP 6.2
the is_block_theme
prop from useIsBlockBasedTheme
hook is not present. It was added directly in core for 6.3. Since we support one more WP version though and we should add it in GB too. I've opened a PR for that.
Flaky tests detected in 9295a46. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5926204937
|
Should be able to close #52154, #52847
Related to #53123
What?
This PR fixes the following two issues in the command palette:
In the classic theme and the hybrid theme, accessing a searched page would take you to the Site Editor which you do not have permission to access.
Screencast
1901407c5505b05e994882595b0f7ab5.mp4
In all themes, accessing a searched post takes you to a page where the Site Editor does not exist.
Screencast
fa4b34bf18b43350c6b5517e66c8fd14.mp4
Why?
For pages, you should go to the Pages menu in the Site Editor for block themes and to the normal edit page for non-block themes.
For posts, you should go to the normal edit page regardless of the theme type, as it is not currently implemented in the Site Editor.
How?
These commands are controlled by the
getNavigationCommandLoaderPerPostType()
function. This function handles all posts, pages, templates, and template parts, and therefore contains various conditions based on post type.I have split it into two functions to simplify the process:
getNavigationCommandLoaderPerPostType()
: commands for posts and pagesgetNavigationCommandLoaderPerTemplate()
: commands for templates and template partsAnd in each of these functions, I added processing according to the theme type.
Testing Instructions
Go to
localhost:8889/wp-admin
, open the Command Palette in each theme, and check the following:Block Theme (Twenty Twenty Three)
hello
: should move to the edit post pageprivacy
: should move to the edit page of the Site Editor404
: should move to the template page of the Site Editorheader
: should move to the template part page of the Site EditorHybrid Theme (Emptyhybrid)
hello
: should move to the edit post pageprivacy
: should move to the edit post page404
: the command results should not be displayedheader
: should move to the template part of the Site EditorClassic Theme (Twenty Twenty One)
hello
: should move to the edit post pageprivacy
: should move to the edit post page404
: the command results should not be displayedheader
: the command results should not be displayed