Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
List: make allowedBlocks setting a constant
  • Loading branch information
ellatrix committed Sep 9, 2022
commit 6ca7e4abb3e87a8ddd555735b2a6057fd1ff67eb
4 changes: 3 additions & 1 deletion packages/block-library/src/list-item/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
} from './hooks';
import { convertToListItems } from './utils';

const ALLOWED_BLOCKS = [ 'core/list' ];

export function IndentUI( { clientId } ) {
const [ canIndent, indentListItem ] = useIndentListItem( clientId );
const [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );
Expand Down Expand Up @@ -64,7 +66,7 @@ export default function ListItemEdit( {
const { placeholder, content } = attributes;
const blockProps = useBlockProps( { ref: useCopy( clientId ) } );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/list' ],
allowedBlocks: ALLOWED_BLOCKS,
} );
const useEnterRef = useEnter( { content, clientId } );
const useSpaceRef = useSpace( clientId );
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import TagName from './tag-name';

const TEMPLATE = [ [ 'core/list-item' ] ];
const NATIVE_MARGIN_SPACING = 8;
const ALLOWED_BLOCKS = [ 'core/list-item' ];

/**
* At the moment, deprecations don't handle create blocks from attributes
Expand Down Expand Up @@ -128,7 +129,7 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) {
...( Platform.isNative && { style } ),
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/list-item' ],
allowedBlocks: ALLOWED_BLOCKS,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole object passed as the second arg of this useInnerBlocksProps() call could be a constant, couldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be, but I think we shallow compare it anyway, so there would be no point.

template: TEMPLATE,
templateLock: false,
templateInsertUpdatesSelection: true,
Expand Down