New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InserterListItem: use item.isDisabled to detect disabled item #57161
Conversation
Size Change: -2 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense thanks for the fix.
For the suggestion about creating the "blocks" only on drag. It is indeed something that would be a perf optimization but I'm afraid that we're basically removing all (almost) the value of the Draggable
component. So it seems we might want to rethink that component's API.
Maybe all we need is the And in the case of synced patterns, it's currently being overridden dynamically in a somewhat hacky way: gutenberg/packages/block-editor/src/components/inserter-draggable-blocks/index.js Lines 44 to 52 in 8cd528b
A |
@jsnajdr That seems like a reasonable path yes. |
Fixing a little bug I noticed when working on block lazy loading. When
InserterListItem
decides whether the item should be draggable or not, it looks atitem.disabled
, but the real name of the field isitem.isDisabled
! You can see for yourself in functions likegetInserterItems
orbuildBlockTypeItem
that build theseitem
objects.Another fix is correct dependencies in
useMemo
hook that creates the blocks to insert by the drag&drop. TheinnerBlocks
dependency was missing. These data also come frombuildBlockTypeItem
, and their ultimate source is the block registration info and the registered variations. They should be constants.The
createBlocks
call leads me to another idea: as a followup, we should optimizeInserterListItem
andInserterDraggableBlocks
to create the blocks only when we really start the drag&drop process. On the vast majority of inserter render drag&drop is not used, so the blocks are created too eagerly.Also, if drag&drop is disabled, like it always is in the Quick Inserter, we don't need to render
InserterDraggableBlocks
at all, it acts as a pass-through noop anyway. Let's render theInserterListboxItem
directly.WDYT?