Skip to content

Commit

Permalink
fix: use synced attributes for ListContainer directly (#73)
Browse files Browse the repository at this point in the history
* fix: use synced attributes for ListContainer directly

* fix: remove undefined variable
  • Loading branch information
dkoo authored Jun 21, 2021
1 parent cdbc0bb commit f8641a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ node_modules
/bin
/src/**/*.js
*.scss
import
16 changes: 4 additions & 12 deletions src/blocks/list-container/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -93,26 +92,19 @@ const ListContainerEditorComponent = ( { clientId, innerBlocks, isSelected, pare
'newspack-listings/marketplace',
'newspack-listings/place',
] }
renderAppender={ () =>
queryMode || ( ! isSelected && ! parentIsSelected ) ? null : (
<InnerBlocks.ButtonBlockAppender />
)
}
renderAppender={ () => <InnerBlocks.ButtonBlockAppender /> }
/>
</div>
);
};

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,
};
};

Expand Down

0 comments on commit f8641a7

Please sign in to comment.