Skip to content

Commit

Permalink
Improve code legibility
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Dec 4, 2023
1 parent f2bde2a commit 2817be2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions packages/dataviews/src/view-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export default function ViewList( {
/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */
<li
key={ getItemId?.( item ) || index }
onClick={ () => {
onSelectionChange( [ item ] );
} }
onClick={ () => onSelectionChange( [ item ] ) }
>
<HStack>
{ primaryField?.render( { item } ) }
Expand Down
12 changes: 6 additions & 6 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -326,13 +327,12 @@ export default function PagePages() {
{ view.type === LAYOUT_LIST && (
<Page>
<div className="edit-site-page-pages-preview">
{ previewItem && (
{ pageId !== null ? (
<SideEditor
postId={ previewItem }
postId={ pageId }
postType={ postType }
/>
) }
{ ! previewItem && (
) : (
<div
style={ {
display: 'flex',
Expand Down

0 comments on commit 2817be2

Please sign in to comment.