Problem/Motivation

Duplicate puts a copy next to the node, in the same root or slot. When that root or slot is full, the copy is refused with "There is no room left here.", from #3626659: Paste, duplicate and preset insert end in a server error when the target is full or gone. The contextual menu still offers Duplicate there, and so does the mod+d shortcut.

It always happens on the root node of a pattern preset: the root of a preset holds one node. It also happens on the root of an entity view override limited by its field, and in a slot whose component sets a maximum.

Nodes inside a slot with room left duplicate as before, in a preset builder too.

The builder already knows. Every limited dropzone carries data-max-items, the root and the slots, from ViewPanelBase::addDropzoneConstraints(). Drag and drop reads it: isDropzoneFull() in dropzone.js refuses a drop into a full dropzone before any request.

Steps to reproduce

  1. Open the builder of a pattern preset.
  2. Right-click its root node and choose Duplicate.
  3. The toast says there is no room left. Nothing told the user before the click.

Proposed resolution

  • Disable Duplicate in the contextual menu when the dropzone around the node is full, and say why in the item itself: "Duplicate: no room left here". The menu already rewrites the label of Paste and Remove when it opens, in updateMenuItems().
  • The reason is the item's text, not a tooltip. A tooltip needs a hover, which a keyboard user does not have and a disabled item may not react to.
  • mod+d keeps sending the request and showing the toast: there is no menu to carry the reason. A disabled state left by an earlier right-click must not swallow it.
  • One check shared with drag and drop, not a second copy of isDropzoneFull().
  • The server check and its toast stay: the screen can be out of date.
  • A Playwright test with a slot that has a maximum: Duplicate is enabled below it, and disabled with its reason once it is reached.

Remaining tasks

  • Settle the wording of the reason.
  • Decide whether Paste gets the same check on its destination. Paste is already disabled with no reason when nothing was copied: the same rule could cover it.

User interface changes

Duplicate is disabled where the copy has no room, and its label says so.

API changes

None.

Data model changes

None.

Comments

mogtofu33 created an issue. See original summary.