From c8d7cacd8d6dca22f8b836c9b3a7953b96ae97e9 Mon Sep 17 00:00:00 2001 From: dhruvang21 Date: Thu, 10 Oct 2024 19:26:26 +0530 Subject: [PATCH 1/2] Fix: pattern rendering issue --- packages/edit-site/src/components/page-patterns/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index be3bb7429c32f..a75573918b88d 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -78,6 +78,7 @@ export default function DataviewsPatterns() { const categoryId = categoryIdFromURL || PATTERN_DEFAULT_CATEGORY; const [ view, setView ] = useState( DEFAULT_VIEW ); const previousCategoryId = usePrevious( categoryId ); + const previouspostType = usePrevious( type ); const viewSyncStatus = view.filters?.find( ( { field } ) => field === 'sync-status' )?.value; @@ -121,10 +122,10 @@ export default function DataviewsPatterns() { // Reset the page number when the category changes. useEffect( () => { - if ( previousCategoryId !== categoryId ) { + if ( previousCategoryId !== categoryId || previouspostType !== type ) { setView( ( prevView ) => ( { ...prevView, page: 1 } ) ); } - }, [ categoryId, previousCategoryId ] ); + }, [ categoryId, previousCategoryId, previouspostType, type ] ); const { data, paginationInfo } = useMemo( () => { // Search is managed server-side as well as filters for patterns. // However, the author filter in template parts is done client-side. From 68ddc279e2690fad95af8171724e6b2a9af9228d Mon Sep 17 00:00:00 2001 From: Ramon Date: Fri, 11 Oct 2024 13:59:06 +1100 Subject: [PATCH 2/2] Use camel case --- packages/edit-site/src/components/page-patterns/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index a75573918b88d..69ebf66093806 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -78,7 +78,7 @@ export default function DataviewsPatterns() { const categoryId = categoryIdFromURL || PATTERN_DEFAULT_CATEGORY; const [ view, setView ] = useState( DEFAULT_VIEW ); const previousCategoryId = usePrevious( categoryId ); - const previouspostType = usePrevious( type ); + const previousPostType = usePrevious( type ); const viewSyncStatus = view.filters?.find( ( { field } ) => field === 'sync-status' )?.value; @@ -122,10 +122,10 @@ export default function DataviewsPatterns() { // Reset the page number when the category changes. useEffect( () => { - if ( previousCategoryId !== categoryId || previouspostType !== type ) { + if ( previousCategoryId !== categoryId || previousPostType !== type ) { setView( ( prevView ) => ( { ...prevView, page: 1 } ) ); } - }, [ categoryId, previousCategoryId, previouspostType, type ] ); + }, [ categoryId, previousCategoryId, previousPostType, type ] ); const { data, paginationInfo } = useMemo( () => { // Search is managed server-side as well as filters for patterns. // However, the author filter in template parts is done client-side.