Skip to content

Commit

Permalink
Revert "Composite: fix legacy implementation passing store prop (Word…
Browse files Browse the repository at this point in the history
…Press#65821)"

This reverts commit 7f08622.
  • Loading branch information
huubl authored Oct 2, 2024
1 parent bfc4332 commit ff64769
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 49 deletions.
1 change: 0 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- `Navigator`: fix `isInitial` logic ([#65527](https://github.com/WordPress/gutenberg/pull/65527)).
- `ToggleGroupControl`: Fix arrow key navigation in RTL ([#65735](https://github.com/WordPress/gutenberg/pull/65735)).
- `ToggleGroupControl`: indicator doesn't jump around when the layout around it changes ([#65175](https://github.com/WordPress/gutenberg/pull/65175)).
- `Composite`: fix legacy support for the store prop ([#65821](https://github.com/WordPress/gutenberg/pull/65821)).

### Deprecations

Expand Down
12 changes: 5 additions & 7 deletions packages/components/src/composite/group-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ export const CompositeGroupLabel = forwardRef<
WordPressComponentProps< CompositeGroupLabelProps, 'div', false >
>( function CompositeGroupLabel( props, ref ) {
const context = useCompositeContext();

// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer. The `store` prop is documented, but its type is
// obfuscated to discourage its use outside of the component's internals.
const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;

return (
<Ariakit.CompositeGroupLabel store={ store } { ...props } ref={ ref } />
<Ariakit.CompositeGroupLabel
store={ context.store as Ariakit.CompositeStore }
{ ...props }
ref={ ref }
/>
);
} );
14 changes: 7 additions & 7 deletions packages/components/src/composite/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const CompositeGroup = forwardRef<
WordPressComponentProps< CompositeGroupProps, 'div', false >
>( function CompositeGroup( props, ref ) {
const context = useCompositeContext();

// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer. The `store` prop is documented, but its type is
// obfuscated to discourage its use outside of the component's internals.
const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;

return <Ariakit.CompositeGroup store={ store } { ...props } ref={ ref } />;
return (
<Ariakit.CompositeGroup
store={ context.store as Ariakit.CompositeStore }
{ ...props }
ref={ ref }
/>
);
} );
14 changes: 7 additions & 7 deletions packages/components/src/composite/hover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const CompositeHover = forwardRef<
WordPressComponentProps< CompositeHoverProps, 'div', false >
>( function CompositeHover( props, ref ) {
const context = useCompositeContext();

// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer. The `store` prop is documented, but its type is
// obfuscated to discourage its use outside of the component's internals.
const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;

return <Ariakit.CompositeGroup store={ store } { ...props } ref={ ref } />;
return (
<Ariakit.CompositeHover
store={ context.store as Ariakit.CompositeStore }
{ ...props }
ref={ ref }
/>
);
} );
7 changes: 1 addition & 6 deletions packages/components/src/composite/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ export const Composite = Object.assign(
},
ref
) {
// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer.
const storeProp = props.store as Ariakit.CompositeStore;
const internalStore = Ariakit.useCompositeStore( {
const store = Ariakit.useCompositeStore( {
activeId,
defaultActiveId,
setActiveId,
Expand All @@ -88,8 +85,6 @@ export const Composite = Object.assign(
rtl,
} );

const store = storeProp ?? internalStore;

const contextValue = useMemo(
() => ( {
store,
Expand Down
14 changes: 7 additions & 7 deletions packages/components/src/composite/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const CompositeItem = forwardRef<
WordPressComponentProps< CompositeItemProps, 'button', false >
>( function CompositeItem( props, ref ) {
const context = useCompositeContext();

// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer. The `store` prop is documented, but its type is
// obfuscated to discourage its use outside of the component's internals.
const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;

return <Ariakit.CompositeItem store={ store } { ...props } ref={ ref } />;
return (
<Ariakit.CompositeItem
store={ context.store as Ariakit.CompositeStore }
{ ...props }
ref={ ref }
/>
);
} );
14 changes: 7 additions & 7 deletions packages/components/src/composite/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const CompositeRow = forwardRef<
WordPressComponentProps< CompositeRowProps, 'div', false >
>( function CompositeRow( props, ref ) {
const context = useCompositeContext();

// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer. The `store` prop is documented, but its type is
// obfuscated to discourage its use outside of the component's internals.
const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;

return <Ariakit.CompositeRow store={ store } { ...props } ref={ ref } />;
return (
<Ariakit.CompositeRow
store={ context.store as Ariakit.CompositeStore }
{ ...props }
ref={ ref }
/>
);
} );
14 changes: 7 additions & 7 deletions packages/components/src/composite/typeahead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const CompositeTypeahead = forwardRef<
WordPressComponentProps< CompositeTypeaheadProps, 'div', false >
>( function CompositeTypeahead( props, ref ) {
const context = useCompositeContext();

// @ts-expect-error The store prop is undocumented and only used by the
// legacy compat layer. The `store` prop is documented, but its type is
// obfuscated to discourage its use outside of the component's internals.
const store = ( props.store ?? context.store ) as Ariakit.CompositeStore;

return <Ariakit.CompositeRow store={ store } { ...props } ref={ ref } />;
return (
<Ariakit.CompositeTypeahead
store={ context.store as Ariakit.CompositeStore }
{ ...props }
ref={ ref }
/>
);
} );

0 comments on commit ff64769

Please sign in to comment.