From f8641a726ce7c2949c01b232829f8923f06b61ad Mon Sep 17 00:00:00 2001 From: Derrick Koo Date: Mon, 21 Jun 2021 14:44:46 -0600 Subject: [PATCH] fix: use synced attributes for ListContainer directly (#73) * fix: use synced attributes for ListContainer directly * fix: remove undefined variable --- .distignore | 1 + src/blocks/list-container/edit.js | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.distignore b/.distignore index f414a416..67346de2 100644 --- a/.distignore +++ b/.distignore @@ -30,3 +30,4 @@ node_modules /bin /src/**/*.js *.scss +import diff --git a/src/blocks/list-container/edit.js b/src/blocks/list-container/edit.js index c11affec..a7473ebb 100644 --- a/src/blocks/list-container/edit.js +++ b/src/blocks/list-container/edit.js @@ -7,9 +7,8 @@ import { Notice, PanelRow, Spinner } from '@wordpress/components'; import { compose } from '@wordpress/compose'; import { withDispatch, withSelect } from '@wordpress/data'; -const ListContainerEditorComponent = ( { clientId, innerBlocks, isSelected, parent } ) => { - const parentAttributes = parent.attributes || {}; - const { queryMode, queryOptions, isSelected: parentIsSelected, showSortUi } = parentAttributes; +const ListContainerEditorComponent = ( { attributes, clientId, innerBlocks } ) => { + const { queryMode, queryOptions, showSortUi } = attributes; const { order } = queryOptions; if ( queryMode && ! showSortUi ) { @@ -93,11 +92,7 @@ const ListContainerEditorComponent = ( { clientId, innerBlocks, isSelected, pare 'newspack-listings/marketplace', 'newspack-listings/place', ] } - renderAppender={ () => - queryMode || ( ! isSelected && ! parentIsSelected ) ? null : ( - - ) - } + renderAppender={ () => } /> ); @@ -105,14 +100,11 @@ const ListContainerEditorComponent = ( { clientId, innerBlocks, isSelected, pare const mapStateToProps = ( select, ownProps ) => { const { clientId } = ownProps; - const { getBlock, getBlockParents } = select( 'core/block-editor' ); + const { getBlock } = select( 'core/block-editor' ); const innerBlocks = getBlock( clientId ).innerBlocks || []; - const parentId = getBlockParents( clientId )[ 0 ] || null; - const parent = getBlock( parentId ); return { innerBlocks, - parent, }; };