From 246258c765e8d44623e72fbb629a8c21b6e25650 Mon Sep 17 00:00:00 2001 From: Hiroshi Urabe Date: Wed, 30 Oct 2024 16:52:51 +0900 Subject: [PATCH 01/10] Fix Parent Check Condition in `buildTermsTree` (#66006) * Use undefined instead of null in `buildTermsTree` * allow null * use undefined * remove null checking --- packages/editor/src/utils/terms.js | 6 ++++-- packages/editor/src/utils/test/terms.js | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/utils/terms.js b/packages/editor/src/utils/terms.js index 2d34879548a56c..e3154a6480a0fa 100644 --- a/packages/editor/src/utils/terms.js +++ b/packages/editor/src/utils/terms.js @@ -14,14 +14,16 @@ export function buildTermsTree( flatTerms ) { const flatTermsWithParentAndChildren = flatTerms.map( ( term ) => { return { children: [], - parent: null, + parent: undefined, ...term, }; } ); // All terms should have a `parent` because we're about to index them by it. if ( - flatTermsWithParentAndChildren.some( ( { parent } ) => parent === null ) + flatTermsWithParentAndChildren.some( + ( { parent } ) => parent === undefined + ) ) { return flatTermsWithParentAndChildren; } diff --git a/packages/editor/src/utils/test/terms.js b/packages/editor/src/utils/test/terms.js index 68a1a7f10fb190..fa7d1622370c7a 100644 --- a/packages/editor/src/utils/test/terms.js +++ b/packages/editor/src/utils/test/terms.js @@ -4,14 +4,14 @@ import { buildTermsTree } from '../terms'; describe( 'buildTermsTree()', () => { - it( 'Should return same array as input with null parent and empty children added if parent is never specified.', () => { + it( 'Should return same array as input with undefined parent and empty children added if parent is never specified.', () => { const input = Object.freeze( [ { id: 2232, dummy: true }, { id: 2245, dummy: true }, ] ); const output = Object.freeze( [ - { id: 2232, parent: null, children: [], dummy: true }, - { id: 2245, parent: null, children: [], dummy: true }, + { id: 2232, parent: undefined, children: [], dummy: true }, + { id: 2245, parent: undefined, children: [], dummy: true }, ] ); const termsTreem = buildTermsTree( input ); expect( termsTreem ).toEqual( output ); From 49a931897ac2a5d438f05dbaaa59ceedab71a0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:45:30 +0100 Subject: [PATCH 02/10] Templates: hide mediaField in list view if not provided (#66573) Co-authored-by: oandregal Co-authored-by: ntsekouras --- .../dataviews/src/dataviews-layouts/list/index.tsx | 12 +++++------- .../dataviews/src/dataviews-layouts/list/style.scss | 6 ------ .../edit-site/src/components/page-templates/index.js | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/packages/dataviews/src/dataviews-layouts/list/index.tsx b/packages/dataviews/src/dataviews-layouts/list/index.tsx index 82f9b5ea4d4fc5..a4f94e482c69b3 100644 --- a/packages/dataviews/src/dataviews-layouts/list/index.tsx +++ b/packages/dataviews/src/dataviews-layouts/list/index.tsx @@ -176,10 +176,10 @@ function ListItem< Item >( { }, [ actions, item ] ); const renderedMediaField = mediaField?.render ? ( - - ) : ( -
- ); +
+ +
+ ) : null; const renderedPrimaryField = primaryField?.render ? ( @@ -248,9 +248,7 @@ function ListItem< Item >( { /> -
- { renderedMediaField } -
+ { renderedMediaField }