FIRST BE AWARE OF THIS: This is potentially something that doesn't warrant much concern, provided these two things happen:

  1. The issue creating a Splitbutton render element lands: #1899236: Add new Splitbutton render element to eventually replace Dropbutton
  2. 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

Comments

bnjmnm created an issue. See original summary.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

darvanen’s picture

Experiencing this with the graphql module's server list. The items aren't even that long.

sakthivel m’s picture

Status: Active » Needs review
StatusFileSize
new1.88 KB

#5 Please review the patch

darvanen’s picture

Well... 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?

bnjmnm’s picture

Re: #6

I'm not sure whether that's something that should be solved here or as a follow-up.

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 🙂

darvanen’s picture

Yeah 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.

bnjmnm’s picture

#8

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 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:

  • Moving the cursor behavior to a followup would be preferred because:
    1. Anything that can be split into another issue probably should, for ease of review and to ensure that a bug fix is not delayed due to changes that aren't necessary to fixing the bug
    2. What you spotted also seems to be an issue in Seven, while the bug reported in the issue summary is specific to Claro. A solution would happen in Dropbutton itself as oppposed to the implementation in a specific theme.
  • Regarding the overall prioritizing splitbutton over dropbutton improvements (bugs should still be prioritized)
    1. It's incredibly difficult to make dropbutton improvements happen in a way that fulfills Drupal's backwards compatibility policy. There are several dropbutton issues that have been open for years and this is one of the bigger things preventing them from landing.
    2. Splitbutton, as-is, fixes many of the open-for-years dropbutton issues.
    3. Many of dropbutton's problems are due to its very clever but somewhat fragile implementation. It is an unordered list of links that is transformed into buttons and toggles via JavaScript. It requires very specific conditions to work properly.
    4. Expanding on the previous point, dropbutton is semantically incorrect so it can confuse assistive tech.
    5. Splitbuttons can be styled using the same classes as regular buttons. Buttons and Splitbuttons can be made primary/warning/small/etc exactly the same way. Dropbuttons require their own dropbutton-specific implementations of these variants. Things like changing button size in dropbutton require dozens of CSS lines, while splitbutton simply works.

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 :)

darvanen’s picture

Thanks 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.

darvanen’s picture

Status: Needs review » Needs work
StatusFileSize
new124.71 KB

Ok.... found an issue with this approach in views:

rikki_iki’s picture

Can 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.

rikki_iki’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB

This patch makes the change only applicable to dropbuttons inside a td.

vikashsoni’s picture

StatusFileSize
new2.61 MB
new2.1 MB

Applied patch #5 working fine after patch the issue fixed
Thanks for the patch for reference sharing

bnjmnm’s picture

Status: Needs review » Needs work

This looks like a nice solution. I spotted a few refinements I'd like to see:

  1. +++ b/core/themes/claro/css/components/dropbutton.pcss.css
    @@ -46,11 +46,32 @@
    +@media screen and (min-width: 48em) {
    

    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.

  2. +++ b/core/themes/claro/css/components/dropbutton.pcss.css
    @@ -46,11 +46,32 @@
    +    position: absolute;
    

    This should target the .dropbutton-multiple class 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-widget as 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)

rikki_iki’s picture

Issue tags: +#pnx-sprint
StatusFileSize
new150.09 KB

Definitely 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.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mherchel’s picture

Status: Needs work » Needs review
StatusFileSize
new862 bytes

IMHO the previous solutions are too complicated.

In this patch (which is what we do in Olivero), we use visibility: hidden to hide the hidden <li> elements instead of display: none.

While both rules remove the elements from the browser's accessibility tree, the difference is that visibility: hidden will reserve space for the elements, while display: none will not (it will effectively remove the elements from the DOM).

lauriii’s picture

I 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?

darvanen’s picture

Status: Needs review » Reviewed & tested by the community

+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.

ckrina’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
StatusFileSize
new39 KB
new52.25 KB
new15.3 KB

I'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-width to .dropbutton--extrasmall, something like width: calc(100% - 0.5rem);. Then the .dropbutton-togglewould need to be moved too and the shadow from .dropbutton-widgetwould need to be adjusted too:

mherchel’s picture

Status: Needs work » Needs review
StatusFileSize
new13.82 KB
new1.81 KB
new26.67 KB

but this breaks the design by leaving this huge space between the button word and the toggle. I

This 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.

mherchel’s picture

Issue summary: View changes
StatusFileSize
new131.81 KB

Uploading correct animated gif

mherchel’s picture

Ugh. I also accidentally uploaded a D10 patch for Olivero. Please ignore that! :D

rikki_iki’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new9.07 KB
new16.72 KB

I 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.

Only local images are allowed.

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.

rikki_iki’s picture

StatusFileSize
new125.91 KB

ugh, failing at screenshots today!

ckrina’s picture

Issue summary: View changes
Related issues: +#1899236: Add new Splitbutton render element to eventually replace Dropbutton
StatusFileSize
new18.14 KB
new11.45 KB
new83.16 KB

This only happens if there is an extreme amount of text

It 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.

  • ckrina committed 92e3e65 on 9.4.x
    Issue #3168326 by mherchel, rikki_iki, Sakthivel M, ckrina, bnjmnm,...
ckrina’s picture

Version: 9.4.x-dev » 10.0.x-dev

Committed 92e3e65 and pushed to 9.4.x. Thanks!

  • ckrina committed 65c863b on 10.0.x
    Issue #3168326 by mherchel, rikki_iki, Sakthivel M, ckrina, bnjmnm,...
ckrina’s picture

Status: Reviewed & tested by the community » Fixed

Committed 65c863b and pushed to 10.0.x too. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.