diff --git a/packages/dataviews/src/view-list.js b/packages/dataviews/src/view-list.js index 151654b5f8243..ad9523d4e3b4d 100644 --- a/packages/dataviews/src/view-list.js +++ b/packages/dataviews/src/view-list.js @@ -25,9 +25,7 @@ export default function ViewList( { /* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */
  • { - onSelectionChange( [ item ] ); - } } + onClick={ () => onSelectionChange( [ item ] ) } > { primaryField?.render( { item } ) } diff --git a/packages/edit-site/src/components/page-pages/index.js b/packages/edit-site/src/components/page-pages/index.js index adce6d5e512f6..3033ee190e62c 100644 --- a/packages/edit-site/src/components/page-pages/index.js +++ b/packages/edit-site/src/components/page-pages/index.js @@ -128,9 +128,10 @@ const DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'tra export default function PagePages() { const postType = 'page'; const [ view, setView ] = useView( postType ); - const [ previewItem, setPreview ] = useState(); + const [ pageId, setPageId ] = useState( null ); - const onSelectionChange = ( item ) => setPreview( item.id ); + const onSelectionChange = ( items ) => + setPageId( items?.length === 1 ? items[ 0 ].id : null ); const queryArgs = useMemo( () => { const filters = {}; @@ -326,13 +327,12 @@ export default function PagePages() { { view.type === LAYOUT_LIST && (
    - { previewItem && ( + { pageId !== null ? ( - ) } - { ! previewItem && ( + ) : (