FIRST BE AWARE OF THIS: This is potentially something that doesn't warrant much concern, provided these two things happen:
- The issue creating a Splitbutton render element lands: #1899236: Add new Splitbutton render element to eventually replace Dropbutton
- After that issue lands, all Claro instances of dropbuttons inside tables can be replaced with splitbuttons.
If this is a straightforward fix, it should happen regardless of the above. If it proves trickier, it's possible that time would be better spent getting the above items taken care of.
Problem/Motivation
If a dropbutton is in a table cell and includes a long list item, opening it can result in a resize that moves the pointer outside of the target area, which results in the dropbutton closing immediately after it opens and the list items impossible to reach (via pointer device, at least)

This does not happen in Seven since table cell width is not impacted by the dropbutton opening. This has other drawbacks, such as the options and disclosure button overflowing outside of the viewport.

Steps to reproduce
Go to the manage fields form for a content type.
Use developer tools to change one of the operations dropbutton choices to something longer. I used "I am an irritatingly long option"
The viewport needs to be fairly wide so the table cell width changes enough to displace the pointer. I could reliably reproduce the problem at viewports over 1300px.
Proposed resolution
?
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | space.png | 83.16 KB | ckrina |
| #27 | open-state.png | 11.45 KB | ckrina |
| #27 | close-state.png | 18.14 KB | ckrina |
| #26 | after-22-views-layout.png | 125.91 KB | rikki_iki |
| #25 | after-22.png | 16.72 KB | rikki_iki |
Comments
Comment #4
darvanenExperiencing this with the graphql module's server list. The items aren't even that long.
Comment #5
sakthivel m commented#5 Please review the patch
Comment #6
darvanenWell... it applies cleanly and it does keep the dropbutton open.
The next poblem this shows up is that the dropbutton open handle moves to the right, away from the cursor, which is less than desireable. I'm not sure whether that's something that should be solved here or as a follow-up.
Just a thought - views has a 'responsive' mechanism with values low, medium and high that determine how much a column changes size in situations like this. How does that work? Is that something that can be implemented by this theme on operations columns?
Comment #7
bnjmnmRe: #6
Definitely a followup. The symptom addressed in this issue is one that can make a dropbutton fully unusable with pointer devices. What you've pointed out is certainly less than ideal, but it still functions.
There's a chance an issue already exists, as there are dozens of Dropbutton related issues regarding it's overall fussiness. Dropbuttons are very difficult to modify without unintended drawbacks. My preference would be landing this issue : #1899236: Add new Splitbutton render element to eventually replace Dropbutton. This creates a new "splitbutton" render element that can fully replace dropbutton + has many additional features. It's just sitting around waiting for reviews and would be a very pleasant addition to core 🙂
Comment #8
darvanenYeah I'm following that one too.
Do we know what the core team's preference is? Are you on any of the core teams? (Sorry if I'm supposed to know that)
I agree consolidating effort would be a good thing.
Comment #9
bnjmnm#8
I am on a team dedicated to working on Drupal core, and there's definitely no expectation for anyone to be aware of that 🙂.
I appreciate this being asked, I'll explain some of the rationale:
This can probably be distilled to "this is the approach most likely to actually get improvements committed to Drupal instead of dying on the vine". Splitbutton will solve many annoyances, but it's also a giant merge request so it's understandable there isn't a pool of people excited to review it :)
Comment #10
darvanenThanks for that excellently clear explanation :)
Agree on all points.
For this issue: I call it functionally reviewed, and I would mark this RTBC but I'm not 100% up on the preferences of the Claro theme when it comes to CSS inclusion. I think that level of code review needs someone who has worked on the theme to take a look.
Comment #11
darvanenOk.... found an issue with this approach in views:
Comment #12
rikki_iki commentedCan be make this change more targeted to only dropbuttons inside tables? Given that's the place they're broken, then it won't effect the views ui.
Comment #13
rikki_iki commentedThis patch makes the change only applicable to dropbuttons inside a
td.Comment #14
vikashsoni commentedApplied patch #5 working fine after patch the issue fixed
Thanks for the patch for reference sharing
Comment #15
bnjmnmThis looks like a nice solution. I spotted a few refinements I'd like to see:
Although its less likely to occur, the problem reported can still happen at widths under 48em. This should either not be in a media query, or an additional style needs to be added for widths under 48em.
This should target the
.dropbutton-multipleclass so it is not applied to single item dropbuttons. Absolute positioning on a dropbutton with no added items can confuse table layout computations.It may be possible to use this instead of
.dropbutton-widgetas they appear in the same element.Would also be nice to get screenshot confirmation that #13 addresses the Views issue reported in #11 (it certainly looks like it would, but that confirmation will help this land)
Comment #16
rikki_iki commentedDefinitely needs a bit more work, I'll review the breakpoint tomorrow as I've been using my patch and am still seeing it popup in tables in some occasions. Going to work on this tomorrow.
Screenshot attached from views showing the fix.
Comment #18
mherchelIMHO the previous solutions are too complicated.
In this patch (which is what we do in Olivero), we use
visibility: hiddento hide the hidden<li>elements instead ofdisplay: none.While both rules remove the elements from the browser's accessibility tree, the difference is that
visibility: hiddenwill reserve space for the elements, whiledisplay: nonewill not (it will effectively remove the elements from the DOM).Comment #19
lauriiiI guess there's the trade-off that the main button is now sized according to the widest item in the tray, which wasn't the case before. I think this would be fine as a trade-off for addressing this bug until we have implemented split button. What do others think?
Comment #20
darvanen+1 for clean simple solutions!
I have manually tested this in an environment that experienced this issue in multiple places and it is working nicely, thanks @mherchel.
As for code review I see nothing out place. I've checked and it seems there's no change in functionality for screen readers so there's no regression there.
I'd say #18 passes community review.
Comment #21
ckrinaI'm really sorry, but this brokes the design by leaving this huge space between the button word and the toggle. I understand the reasoning behind the technical solution, but the visual result goes too far for what it solves.
IMHO the patch from #13 also solves the problem without that huge visual impact by default, since the difference is just shown when it's hovered.
But added to the feedback on #15, I've also spotted something thaton a design perspective isn't quite right: the button goes to the right of the screen.
It can give the impression that it's partially hidden, so the right design solution would be to leave a few pixels to make it clear it's the intended behavior. Doing some tests seems like a possible way to fix it would be to add a
max-widthto.dropbutton--extrasmall, something likewidth: calc(100% - 0.5rem);. Then the.dropbutton-togglewould need to be moved too and the shadow from.dropbutton-widgetwould need to be adjusted too:Comment #22
mherchelThis only happens if there is an extreme amount of text in any of the dropdowns. I personally don't know of any core or contrib configurations that would cause this to happen. Nevertheless, it is possible!
Attached is a patch very similar to #18, but with a max-width set to 200px (animated gif below).
IMHO This is a really good compromise that resolves 99.9% of the use cases. Anything outside of that is still usable.
If you think this approach is a dead end, let me know.
Comment #23
mherchelUploading correct animated gif
Comment #24
mherchelUgh. I also accidentally uploaded a D10 patch for Olivero. Please ignore that! :D
Comment #25
rikki_iki commentedI do like the clean solution in #22, the max width seems a suitable work around.
Noting that this applied to all dropbuttons instead of just ones in table cells where the issue was present. I've checked the views layout (screenshot attached) and a few other pages, and see no issue with the results of this change... Especially given this issue is a temporary fix until splitbutton arrives.
Though it would be a simple enough change to make it targeted to tables again.
Aside from that, the patch applies, before/after screenshots attached, code is good, no new issues introduced. Going to mark this RTBC.
Comment #26
rikki_iki commentedugh, failing at screenshots today!
Comment #27
ckrinaIt does happen any time the content in the hidden area is bigger than the button text. :)
See an example:

As background, this is the design specification:
I can understand this is solving a UX problem but it's breaking the design on the resting/closed state. I think UX is more important than design here, and also I expect this is going to be solved in the future by #1899236: Add new Splitbutton render element to eventually replace Dropbutton. So I'll +1 this while my designer self goes to cry to a corner.
Comment #29
ckrinaCommitted 92e3e65 and pushed to 9.4.x. Thanks!
Comment #31
ckrinaCommitted 65c863b and pushed to 10.0.x too. Thanks!