Skip to content

Commit

Permalink
Reset the custom css in variations if the globals styles are reset
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed May 27, 2024
1 parent 065d794 commit 175619f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { store as coreStore } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { useContext, useMemo, useState } from '@wordpress/element';
import { useContext, useEffect, useMemo, useState } from '@wordpress/element';
import { __experimentalGrid as Grid } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
Expand All @@ -20,8 +20,13 @@ const { GlobalStylesContext } = unlock( blockEditorPrivateApis );

export default function StyleVariationsContainer( { gap = 2 } ) {
const { user } = useContext( GlobalStylesContext );
const [ currentUserStyles ] = useState( { ...user } );
const [ currentUserStyles, setCurrentUserStyles ] = useState( { ...user } );
const userStyles = currentUserStyles?.styles;

useEffect( () => {
setCurrentUserStyles( { ...user } );
}, [ user ] );

const variations = useSelect( ( select ) => {
return select(
coreStore
Expand Down

0 comments on commit 175619f

Please sign in to comment.