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
- Open the builder of a pattern preset.
- Right-click its root node and choose Duplicate.
- 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+dkeeps 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.
Issue fork display_builder-3627023
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mogtofu33 commentedComment #3
mogtofu33 commentedComment #4
pdureau commentedThis is an issue more generic than being full or not.
We already have
isDropzoneLocked(element)indropzone.jswhich is only wrappingisDropzoneFull(element)for now, but there will be other mechanisms locking the dropzone (lock panel, SDC expected constraint...).So, we must check
isDropzoneLocked(element)It is a good idea to add a message in the menu item but there will be many reasons for a slot to be locked, so I will propose something without message for now.
About keyboard shortcuts, I will let the "There is no room left here." message returned by
ApiExceptionSubscriberto not mess with an adjacent scope.Yes, it would be nice to address also "Paste" once "Duplicate" is OK.
How to test
We have a
display_builder_test:test_slot_constraintscomponent withmaxItems: 2inslot_1to test.The menu part:
slot_1There is also a keyboard shortcut part.
Comment #6
pdureau commentedDuplicate is OK:
slot_1Let's try with "Paste" now.
Comment #7
pdureau commented"Paste" works too. The test steps are kind of the same as the "Duplicate" ones.
There are 2 removed lines to be careful about in the MR:
I am not sure why it was removed, but everything I tried work without them.
Comment #8
andres alvarez commentedI did some testing on MR !516 (commit 875278a) with display_builder_test:test_slot_constraints in Firefox.
- Slot with room: Duplicate and Paste are enabled.
- Full slot (slot_1, max 2): Duplicate and Paste are disabled. On 1.0.x both are offered and clicking Duplicate shows "There is no room left here."
- mod+d on a full slot still sends the request and shows the toast.
- Pattern preset root with 1 node and data-max-items=1: Duplicate is disabled.
Comment #9
pdureau commentedThanks Andres. So is it OK ? If so, you can move to RTBC.
Comment #10
andres alvarez commentedComment #11
andres alvarez commentedThanks, pdureau. It's acceptable to me and I set it to RTBC. The suggestions in my previous comment are optional, mainly the test for mod+d on a full slot. The two removed Paste lines come from #3527510 and their condition now lives in the per-item loop, so I don't see a problem removing them. I didn't test Chromium or WebKit.
Comment #12
pdureau commentedMuchas gracias :)
Comment #13
mogtofu33 commentedThanks a lot!
Comment #16
pdureau commentedShipped in beta10 release.