-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrating
InserterListbox
to use updated Composite implementation (#…
…56246) - Removes `__unstableComposite` imports from `@wordpress/components` - Adds private `Composite*` exports from `@wordpress/components` - Refactors `InserterListbox`, `InserterListboxRow` and `InserterListboxItem` to use updated `Composite` components - Additionally updates `BlockTypesList` to ensure listbox items are appropriately grouped
- Loading branch information
Andrew Hayward
committed
Nov 22, 2023
1 parent
de3c98e
commit 014d163
Showing
4 changed files
with
33 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
packages/block-editor/src/components/inserter-listbox/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 6 additions & 12 deletions
18
packages/block-editor/src/components/inserter-listbox/row.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { forwardRef, useContext } from '@wordpress/element'; | ||
import { __unstableCompositeGroup as CompositeGroup } from '@wordpress/components'; | ||
import { forwardRef } from '@wordpress/element'; | ||
import { privateApis as componentsPrivateApis } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import InserterListboxContext from './context'; | ||
import { unlock } from '../../lock-unlock'; | ||
|
||
const { CompositeGroupV2: CompositeGroup } = unlock( componentsPrivateApis ); | ||
|
||
function InserterListboxRow( props, ref ) { | ||
const state = useContext( InserterListboxContext ); | ||
return ( | ||
<CompositeGroup | ||
state={ state } | ||
role="presentation" | ||
ref={ ref } | ||
{ ...props } | ||
/> | ||
); | ||
return <CompositeGroup role="presentation" ref={ ref } { ...props } />; | ||
} | ||
|
||
export default forwardRef( InserterListboxRow ); |