Problem/Motivation
Child of #3617065: Expected components constraints for slots. #3544026: Cardinality constraints for slots enforces maxItems, but nothing in the Builder or the Scaffold tells the user. A full slot just refuses the drop, without saying why, and a click insert from the library lands one level up, #3628802: Insert from the library without dragging. The user learns that a slot takes one element only when it refuses the second.
minItems and expected will add more rules the user cannot see.
Proposed resolution
Show each constraint where the slot is drawn, before the user acts:
maxItems: the slot label gets the count, "Content 1/1", and a full slot looks full.- While dragging, a dropzone that refuses the dragged element, full or not expected, looks closed instead of refusing silently.
minItems: a slot under its minimum says so in its label, as a warning, not an error: SDC only suggests.expected: the slot says what it accepts, on hover.
Where:
- Builder: the slot label, from
data-slot-title, shown while dragging or with the Highlight slot toggle. - Scaffold: the slot card header.
- Navigator: the slot row.
- Assistive tech: the same words in the slot's accessible name, with #3624637: Plan: Builder accessibility and UX.
The server already stamps data-max-items on each dropzone. The count and the other constraints join it as attributes, so CSS and the drag share one source.
Remaining tasks
- Design: label text, the look of a full or closed slot, the warning for
minItems. maxItemsfirst, it is already enforced.minItemsandexpectedonce #3617065: Expected components constraints for slots lands them.
User interface changes
Slots show their limits and what they accept, and look closed when they cannot take more.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | builder-scaffold.jpg | 148.4 KB | juc1 |
| #16 | db-slots-items.jpg | 147.78 KB | juc1 |
Issue fork display_builder-3628832
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
pdureau commentedChanging the tag to have the full remaining scope in a single query: https://www.drupal.org/project/issues/search/display_builder?text=&assig...
Comment #4
pdureau commentedComment #5
pdureau commentedI put "Novice" tag because the difficult part of this ticket is not the implementation, but the UI/UX proposal. It is also a way of welcoming proposal from occasional contributors.
Comment #6
wkr1shna commentedHi! I'd like to contribute to this issue, starting with the `maxItems` part.
My initial proposal is to show the current count in the slot label (for example, `Content 1/1`), visually distinguish full slots, and indicate during dragging when a dropzone cannot accept another item. I'd aim to keep the feedback consistent across the Canvas, Scaffold, and Navigator, while making sure the slot's accessible name communicates the same constraint.
I'll first inspect the existing `data-max-items` handling and the relevant UI components to see how best to implement this without duplicating state.
Does this direction fit what you had in mind? I'm happy to refine the UI proposal before starting the implementation.
Comment #7
pdureau commentedHi Krishna,
Thanks for you interest on this topic.
That an interesting proposal.
However, the information we want to convey is broader than a slot having max items and being full or not. The main information is "can i add something to a slot?
We have
isDropzoneLocked(element)indropzone.jswhich is only wrappingisDropzoneFull(element)for now, but there will be other mechanisms "locking" the dropzone (#3551232: Add a lock system, #3617065: Expected components constraints for slots...).If you can add such count (for example, `Content 1/1`), that's cool, but it must not be added against a more generic and reusable visual clue.
Sounds nice.
Be careful: this ticket is only about displaying information, not about mechanisms preventing adding something to a slot, which has been done in #3627023: Duplicate is offered where it can only fail: a full root or slot
You are welcomed to assign the ticket to you :)
Comment #8
wkr1shna commentedThanks for the clarification! I understand the distinction now: the primary visual clue should communicate whether a slot can accept content, regardless of why the dropzone is locked. The item count can be supplementary information, but it shouldn't be the mechanism users rely on to understand whether adding content is possible.
I'll keep this issue focused on displaying the existing dropzone state, without changing the logic that prevents additions. I'll inspect how `isDropzoneLocked(element)` and the existing dropzone attributes are exposed to the Canvas, Scaffold, and Navigator, then propose a consistent visual treatment before implementing it.
I'll assign the issue to myself as suggested.
Comment #9
pdureau commented"Canvas" is now called "Builder"
Comment #11
wkr1shna commentedComment #12
juc1 commentedI am doing a UX review, will report results later today...
Comment #13
pdureau commentedHi @juc1, please assign to tou if you are doing review.
@wkr1shna is still assigned but has finished they work, so I believe it is OK to switch.
Comment #14
wkr1shna commentedThanks for the update! I'm happy for @juc1 to take over the issue for the UX review. The implementation is pushed to MR !524, and I'm available to address any feedback or follow-up changes that come out of the review.
Comment #15
juc1 commentedComment #16
juc1 commentedUX review of MR !524 using
\tests\modules\display_builder_test\components\test_slot_constraintswithslot title "Slot with 2 items max".
The MR gives very helpful visual information about slot capacity and locked status. A few suggestions:
Currently (without MR):
Slot with 2 items maxWith this MR:
Slot with 2 items max 2/2Suggestion:
Slot with 2 items max (2/2)orSlot with 2 items max (2/2 items used)(Brackets help separate the component author's label from the system metadata, especially when the slot name ends in a number or word like "max").
For slots with
maxItems, a hover tooltip on the slot title would clarify the status for users, for example:"2 / 2 items used - this slot is full and cannot accept more items"
The current inline SVG padlock shape is not clear in my browser - suggestion: change the SVG to the official Bootstrap Icons lock-fill https://icons.getbootstrap.com/icons/lock-fill/ and perhaps make it slightly larger (such as
0.875reminstead of the current0.75rem).@pdureau Even without this MR, slot titles get truncated in the Builder view due to:
Because the count is appended to the end, the new constraint count gets swallowed by the ellipsis (e.g.
🔒 Slot with 2 items m...). Notice that in Scaffold view it does not truncate (second screenshot below).Allowing a bit more width specifically for constrained slots fixes this without changing the global 10rem token:
Item count works correctly:
Truncation in Builder view:
Comment #17
juc1 commented