-
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
Site Editor: Prevent access to the Design/Styles screen from classic themes without StyleBook support #69377
base: router/add-context
Are you sure you want to change the base?
Conversation
Size Change: +345 B (+0.02%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
…themes without StyleBook support
a2305d3
to
997ff86
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. |
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 working well. There are other routes that can be accessed by URL that seem like they should get the same treatment. Would we want to take care of all of them in one PR or split it up?
I have an idea for reducing the changes a little bit:
It seems the patterns sidebar can implicitly determine if it should act as root if there’s no back path.
I might be missing something or perhaps there’s a good reason to make it explicitly controlled.diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
index 4f41413b71..e88e7b6093 100644
--- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
+++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js
@@ -100,10 +100,7 @@ function CategoriesGroup( {
);
}
-export default function SidebarNavigationScreenPatterns( {
- isRoot,
- backPath,
-} ) {
+export default function SidebarNavigationScreenPatterns( { backPath } ) {
const {
query: { postType = 'wp_block', categoryId },
} = useLocation();
@@ -123,7 +120,7 @@ export default function SidebarNavigationScreenPatterns( {
description={ __(
'Manage what patterns are available when editing the site.'
) }
- isRoot={ isRoot }
+ isRoot={ ! backPath }
backPath={ backPath }
content={
<>
diff --git a/packages/edit-site/src/components/site-editor-routes/patterns.js b/packages/edit-site/src/components/site-editor-routes/patterns.js
index b64ea9a599..da4377a479 100644
--- a/packages/edit-site/src/components/site-editor-routes/patterns.js
+++ b/packages/edit-site/src/components/site-editor-routes/patterns.js
@@ -15,16 +15,8 @@ export const patternsRoute = {
isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
? '/'
: undefined;
- const isRoot = ! (
- isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
- );
- return (
- <SidebarNavigationScreenPatterns
- backPath={ backPath }
- isRoot={ isRoot }
- />
- );
+ return <SidebarNavigationScreenPatterns backPath={ backPath } />;
},
content: <PagePatterns />,
mobile( { siteData, query } ) {
@@ -34,17 +26,11 @@ export const patternsRoute = {
isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
? '/'
: undefined;
- const isRoot = ! (
- isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
- );
return !! categoryId ? (
<PagePatterns />
) : (
- <SidebarNavigationScreenPatterns
- backPath={ backPath }
- isRoot={ isRoot }
- />
+ <SidebarNavigationScreenPatterns backPath={ backPath } />
);
},
},
packages/edit-site/src/components/sidebar-navigation-screen-unsupported/index.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Mitchell Austin <[email protected]>
@stokesman Thanks for the review!
That's true.
Yes, once #69299 and this PR are merged, I think the other routes can be addressed in #68950. |
What?
Alternatives to #69043
This PR fixes an issue where classic themes that don't support stylebooks can access stylebooks unintentionally.
Note
This PR is based on #69299. When #69299 is merged, we will change the target branch of this PR to trunk.
Why?
Currently, whether the acitve classic theme supports StyleBook or not, pressing the back button on the Patterns page always takes you to the Design screen, where you can unintentionally access StyleBook by accessing the Styles menu.
How?
In the current Gutenberg spec, whether a classic theme supports StyleBook is determined by the following conditional statement:
We control access to the StyleBook based on this conditional statement.
However, how to expose StyleBook is still under discussion in #68036. If those conditions change, this logic will need to be adjusted.
Testing Instructions
If you want to test a classic theme that does not support StyleBook, enable the Twenty Twenty-One theme and comment out this
editor-styles
theme support.Return to the dashboard instead of the Design screen from the Patterns page
Show a warning message when accessing the Design and Styles screens directly via URL
Enter the following URL in your browser's address bar.
Screenshots or screencast
Screen Relationship Diagram
Follow the flow below to make sure you can move between screens properly.
Desktop
Block Theme, Classic Theme with StyleBook support
Classic Theme without StyleBook support
Mobile
Block Theme, Classic Theme with StyleBook support
Classic Theme without StyleBook support
Warning Message