From 324bbfaaa57ba4fed6e8e06f5e407c10cce513c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:21:37 +0100 Subject: [PATCH] Add details in templates list --- .../src/components/page-templates/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/edit-site/src/components/page-templates/index.js b/packages/edit-site/src/components/page-templates/index.js index fd28c22298ba1..8a40646dcaef0 100644 --- a/packages/edit-site/src/components/page-templates/index.js +++ b/packages/edit-site/src/components/page-templates/index.js @@ -170,6 +170,18 @@ export default function DataviewsTemplates() { [ setTemplateId ] ); + const onDetailsChange = useCallback( + ( items ) => { + if ( items?.length === 1 ) { + history.push( { + postId: items[ 0 ].id, + postType: TEMPLATE_POST_TYPE, + } ); + } + }, + [ history ] + ); + const authors = useMemo( () => { if ( ! allTemplates ) { return EMPTY_ARRAY; @@ -363,6 +375,7 @@ export default function DataviewsTemplates() { view={ view } onChangeView={ onChangeView } onSelectionChange={ onSelectionChange } + onDetailsChange={ onDetailsChange } deferredRendering={ ! view.hiddenFields?.includes( 'preview' ) }