Skip to content

Commit

Permalink
Use actions in the ListItem
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Apr 30, 2024
1 parent b90ec86 commit c260591
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/dataviews/src/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import { unlock } from './lock-unlock';
import ItemActions from './item-actions';

const {
useCompositeStoreV2: useCompositeStore,
Expand All @@ -30,6 +31,7 @@ const {
} = unlock( componentsPrivateApis );

function ListItem( {
actions,
id,
item,
isSelected,
Expand Down Expand Up @@ -115,12 +117,28 @@ function ListItem( {
</HStack>
</CompositeItem>
</div>
<div role="gridcell">
<CompositeItem
// To be able to pass ItemActions directly, it should pass the incoming props to the underlying element:
// https://ariakit.org/guide/composition#custom-components-must-be-open-for-extension
render={ ( props ) => (
<ItemActions
actions={ props.actions }
item={ props.item }
isCompact
/>
) }
item={ item }
actions={ actions }
/>
</div>
</HStack>
</CompositeRow>
);
}

export default function ViewList( {
actions,
data,
fields,
getItemId,
Expand Down Expand Up @@ -192,6 +210,7 @@ export default function ViewList( {
<ListItem
key={ id }
id={ id }
actions={ actions }
item={ item }
isSelected={ item === selectedItem }
onSelect={ onSelect }
Expand Down

0 comments on commit c260591

Please sign in to comment.