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
Global styles: simplify the conditions in GlobalStylesEditorCanvasContainerLink #57144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,7 @@ function GlobalStylesBlockLink() { | |
} | ||
|
||
function GlobalStylesEditorCanvasContainerLink() { | ||
const { goTo, location } = useNavigator(); | ||
const { goTo } = useNavigator(); | ||
const editorCanvasContainerView = useSelect( | ||
( select ) => | ||
unlock( select( editSiteStore ) ).getEditorCanvasContainerView(), | ||
|
@@ -241,25 +241,17 @@ function GlobalStylesEditorCanvasContainerLink() { | |
// to the appropriate screen. This effectively allows deep linking to the | ||
// desired screens from outside the global styles navigation provider. | ||
useEffect( () => { | ||
if ( editorCanvasContainerView === 'global-styles-revisions' ) { | ||
// Switching to the revisions container view should | ||
// redirect to the revisions screen. | ||
goTo( '/revisions' ); | ||
} else if ( | ||
!! editorCanvasContainerView && | ||
location?.path === '/revisions' | ||
) { | ||
// Switching to any container other than revisions should | ||
// redirect from the revisions screen to the root global styles screen. | ||
goTo( '/' ); | ||
} else if ( editorCanvasContainerView === 'global-styles-css' ) { | ||
goTo( '/css' ); | ||
switch ( editorCanvasContainerView ) { | ||
case 'global-styles-revisions': | ||
goTo( '/revisions' ); | ||
break; | ||
case 'global-styles-css': | ||
goTo( '/css' ); | ||
break; | ||
Comment on lines
+248
to
+250
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL: so it looks like from where this one was introduced (#51637) that there's never been a separate "real" container view for the global styles CSS (i.e. a modal-like thingie that sits on top of the editor canvas), but this value for the editor canvas container view is used to enable this redirect to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! In fact, I spent a bit of yesterday trying to remove this as it's not really related to the editor container view. I gathered that using The Thanks for looking under the hood! |
||
default: | ||
goTo( '/' ); | ||
break; | ||
} | ||
|
||
// location?.path is not a dependency because we don't want to track it. | ||
// Doing so will cause an infinite loop. We could abstract logic to avoid | ||
// having to disable the check later. | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [ editorCanvasContainerView, goTo ] ); | ||
Comment on lines
-258
to
255
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really nice getting to remove 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.
Changed because there's already a label
Global styles revisions
on the editor canvas container when revisions is active.