Skip to content

Commit

Permalink
AlignmentMatrixControl: do not use composite store
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Aug 31, 2024
1 parent 2f1e4e3 commit 3ed5268
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/components/src/alignment-matrix-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import clsx from 'clsx';
*/
import { __, isRTL } from '@wordpress/i18n';
import { useInstanceId } from '@wordpress/compose';
import { useCallback } from '@wordpress/element';

/**
* Internal dependencies
*/
import Cell from './cell';
import { Composite } from '../composite';
import { useCompositeStore } from '../composite/store';
import { GridContainer, GridRow } from './styles';
import AlignmentMatrixControlIcon from './icon';
import { GRID, getItemId, getItemValue } from './utils';
Expand All @@ -37,23 +37,26 @@ function UnforwardedAlignmentMatrixControl( {
id
);

const compositeStore = useCompositeStore( {
defaultActiveId: getItemId( baseId, defaultValue ),
activeId: getItemId( baseId, value ),
setActiveId: ( nextActiveId ) => {
const setActiveId = useCallback<
NonNullable< React.ComponentProps< typeof Composite >[ 'setActiveId' ] >
>(
( nextActiveId ) => {
const nextValue = getItemValue( baseId, nextActiveId );
if ( nextValue ) {
onChange?.( nextValue );
}
},
rtl: isRTL(),
} );
[ baseId, onChange ]
);

const classes = clsx( 'component-alignment-matrix-control', className );

return (
<Composite
store={ compositeStore }
defaultActiveId={ getItemId( baseId, defaultValue ) }
activeId={ getItemId( baseId, value ) }
setActiveId={ setActiveId }
rtl={ isRTL() }
render={
<GridContainer
{ ...props }
Expand Down

0 comments on commit 3ed5268

Please sign in to comment.