Skip to content

Group the Matrix block action menu’s “Add … above” items by entry type group - #19370

Open
fabianhaef wants to merge 2 commits into
craftcms:5.xfrom
fabianhaef:matrix-block-menu-groups
Open

Group the Matrix block action menu’s “Add … above” items by entry type group#19370
fabianhaef wants to merge 2 commits into
craftcms:5.xfrom
fabianhaef:matrix-block-menu-groups

Conversation

@fabianhaef

@fabianhaef fabianhaef commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #17594.

In the blocks view mode, each Matrix block’s action menu appends one “Add {type} above” item per entry type, in one flat list — also reported in #17594. We have Matrix fields with 35+ entry types, and the menu becomes a long scrolling list where the only way to find a type is to read every row.

The field’s “+” button already solves this: create-button.twig groups the same entry types by their entry type group and shows a search input above five types. This PR brings the block action menu in line with it:

  1. Group the “Add {type} above” items by entry type group — same collect().groupBy() and {hr, padded: false} / {heading, padded: false, items} structure as create-button.twig. Fields with a single group (or no groups set) render exactly as before.
  2. Show a search input above five entry types (withSearchInput: not staticEntries and entryTypes|length > 5), same threshold as the create button. The search filters all menu items (Collapse, Delete, …), like other searchable disclosure menus — it’s a separate commit so it can be dropped if that’s not wanted.

Drive-by: the trailing {hr: true} is now only added when add items follow, removing a dangling separator at the end of the menu for static blocks (e.g. revision view).

Testing

  • 20 entry types across 6 groups: headings and separators render in field-settings order; activating a grouped item still inserts the block above it; arrow-key navigation skips headings.
  • Searching narrows the menu and hides emptied group headings; activating a filtered item works.
  • Single group / no groups set: unchanged flat menu.
  • Revision view (staticEntries): no add items, no search input, no trailing separator.
  • maxEntries reached: DisclosureMenu.updateVisibility() hides the emptied groups including their headings.

@fabianhaef

Copy link
Copy Markdown
Contributor Author

There’s a follow-up discussion for #17594 in #17600 with a few community suggestions — how this PR relates to them:

  • Nested submenus per group (Notion-style): Craft’s disclosure menus don’t support nested submenus today, so this PR groups inline with headings — the same pattern create-button.twig uses. If submenu support lands later (e.g. via the Display grouped “New entry” buttons as a button group #17731 direction), the grouped structure here maps onto it 1:1.
  • “Delete” being hard to reach: the add items sit below the standard actions, so grouping doesn’t change Delete’s position — and the search input (second commit) gets you to any item by typing a few letters.
  • Keeping the flat view: fields without entry type groups render exactly as before, so the flat list stays available by simply not assigning groups. A dedicated per-field toggle would be a small addition if you’d prefer the choice to be explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.x]: Entry type groups missing from actions menu

1 participant