-
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
Global styles: improve navigation logic for revisions screen #65946
Changes from all commits
28bad8c
50d6cab
b3dcbe2
8602981
d53f641
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 |
---|---|---|
@@ -1,13 +1,7 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
FlexItem, | ||
FlexBlock, | ||
Flex, | ||
Button, | ||
useNavigator, | ||
} from '@wordpress/components'; | ||
import { FlexItem, FlexBlock, Flex, Button } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { styles, seen, backup } from '@wordpress/icons'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
|
@@ -86,21 +80,17 @@ export default function GlobalStylesSidebar() { | |
}, [ shouldClearCanvasContainerView ] ); | ||
|
||
const { setIsListViewOpened } = useDispatch( editorStore ); | ||
const { goTo } = useNavigator(); | ||
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. Great catch 👏 FWIW we should also remove 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. I just did this while testing. 👍🏻 |
||
|
||
const toggleRevisions = () => { | ||
setIsListViewOpened( false ); | ||
if ( isRevisionsStyleBookOpened ) { | ||
goTo( '/' ); | ||
setEditorCanvasContainerView( 'style-book' ); | ||
return; | ||
} | ||
if ( isRevisionsOpened ) { | ||
goTo( '/' ); | ||
setEditorCanvasContainerView( undefined ); | ||
return; | ||
} | ||
goTo( '/revisions' ); | ||
|
||
if ( isStyleBookOpened ) { | ||
setEditorCanvasContainerView( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { | ||
useNavigator, | ||
__experimentalConfirmDialog as ConfirmDialog, | ||
Spinner, | ||
} from '@wordpress/components'; | ||
|
@@ -33,7 +32,6 @@ const { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock( | |
const PAGE_SIZE = 10; | ||
|
||
function ScreenRevisions() { | ||
const { goTo } = useNavigator(); | ||
const { user: currentEditorGlobalStyles, setUserConfig } = | ||
useContext( GlobalStylesContext ); | ||
const { blocks, editorCanvasContainerView } = useSelect( | ||
|
@@ -71,6 +69,8 @@ function ScreenRevisions() { | |
currentEditorGlobalStyles | ||
); | ||
|
||
// The actual code that triggers the revisions screen to navigate back | ||
// to the home screen in in `packages/edit-site/src/components/global-styles/ui.js`. | ||
Comment on lines
+72
to
+73
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. Thanks for the comment 👍 |
||
const onCloseRevisions = () => { | ||
const canvasContainerView = | ||
editorCanvasContainerView === 'global-styles-revisions:style-book' | ||
|
@@ -85,15 +85,6 @@ function ScreenRevisions() { | |
onCloseRevisions(); | ||
}; | ||
|
||
useEffect( () => { | ||
if ( | ||
! editorCanvasContainerView || | ||
! editorCanvasContainerView.startsWith( 'global-styles-revisions' ) | ||
) { | ||
goTo( '/' ); // Return to global styles main panel. | ||
} | ||
}, [ editorCanvasContainerView ] ); | ||
|
||
useEffect( () => { | ||
if ( ! isLoading && revisions.length ) { | ||
setCurrentRevisions( revisions ); | ||
|
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.
All of the
goTo
calls in this file are no-ops, becauseuseNavigator
is being called in a component that is not a child of aNavigator
component.