Skip to content

Commit

Permalink
Fix: Additional CSS button not working after back navigation (WordPre…
Browse files Browse the repository at this point in the history
…ss#68954)

* Reset editor canvas view when navigating away from CSS screen

* Added effect to reset editorCanvasContainerView when navigating away from CSS screen
* Added tracking of previous path using usePrevious hook to detect navigation changes
* Added comparison of current and previous paths to determine when to reset the view
* Reset view to undefined to ensure clean state for next CSS screen activation

* Reset editor canvas view when navigating back from CSS screen

* Added onBack handler to ScreenCSS component
* Added setEditorCanvasContainerView to reset view state
* Added missing dependencies for view state management
* Fixed Additional CSS button not working after navigation

Co-authored-by: Infinite-Null <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent 055f881 commit bfe6dd8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/edit-site/src/components/global-styles/screen-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import { __ } from '@wordpress/i18n';
import { ExternalLink } from '@wordpress/components';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { useDispatch } from '@wordpress/data';

/**
* Internal dependencies
*/
import { unlock } from '../../lock-unlock';
import { store as editSiteStore } from '../../store';
import ScreenHeader from './header';

const { useGlobalStyle, AdvancedPanel: StylesAdvancedPanel } = unlock(
Expand All @@ -26,6 +28,10 @@ function ScreenCSS() {
shouldDecodeEncode: false,
} );

const { setEditorCanvasContainerView } = unlock(
useDispatch( editSiteStore )
);

return (
<>
<ScreenHeader
Expand All @@ -44,6 +50,9 @@ function ScreenCSS() {
</ExternalLink>
</>
}
onBack={ () => {
setEditorCanvasContainerView( undefined );
} }
/>
<div className="edit-site-global-styles-screen-css">
<StylesAdvancedPanel
Expand Down

0 comments on commit bfe6dd8

Please sign in to comment.