Problem/Motivation

If you have dropbutton inside a td which uses input as its buttons, when you expand the dropbutton the item buttons will be too short. They will be only as long as their labels (i.e., value attributes), while the whole dropbutton will have the length of the longest label.

This is for example apparent in Paragraphs. Adding a new paragraph inside a container paragraph:
Too-short options in a nested dropbutton
Only the underlined part of "Add Block" is a button. Clicking to the right of it just closes the dropbutton.

The same behavior can be reproduced in e.g., admin/structure/block by inserting an input option into a dropbutton there. (They normally use only a options.) Like so:
<li class="input-test dropbutton-action secondary-action"><input class="input-test-submit button js-form-submit form-submit" id="input-test" name="input_test" value="IT" type="submit"></li>

This behavior has been introduced in #2282599: Dropdown menus in most of core are broken in Stark.

Proposed resolution

Override /core/themes/stable/css/core/dropbutton/dropbutton.css in /core/themes/seven/css/components/dropbutton.component.css. Set the width of the input to 100% to fix this.

Before and after screenshots in #6.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

VladimirMarko created an issue. See original summary.

VladimirMarko’s picture

Status: Active » Needs review
StatusFileSize
new497 bytes
idebr’s picture

Status: Needs review » Needs work

@VladimirMarko I confirmed the bug, but unfortunately we cannot change stable per https://www.drupal.org/docs/8/core/themes/stable-theme:

Stable theme is designed to be a fence for backward compatibility. The Stable theme markup and CSS will not change so any sub-theme of Stable will know that updates will not cause it to break.

How about we override the selector in Seven's css instead in seven/css/components/dropbutton.component.css with the correct value?

VladimirMarko’s picture

Status: Needs work » Needs review
StatusFileSize
new13.23 KB
new530 bytes

I see. That sounds reasonable.

VladimirMarko’s picture

Issue summary: View changes
idebr’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new31.93 KB
new31.3 KB

@Vladimir Cheers, your change looks great!

Some screencaps for good measure taken with the Paragraphs contributed module:

Dropbutton before:

Dropbutton after:

idebr’s picture

Component: Stable theme » Seven theme
Assigned: VladimirMarko » Unassigned
lauriii’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/themes/seven/css/components/dropbutton.component.css
@@ -46,6 +46,9 @@
+.js td .dropbutton-multiple .dropbutton-action input {

Could this bug exist elsewhere than inside a td element? Is there some problem if we would apply this more globally than just for dropbuttons inside a td?

idebr’s picture

Re #8
This was actually the approach in #2: fix the specificity of the selector in Stable. However, since the css for Stable is supposed to be frozen, we changed the approach in #4

The specificity is required to override the selector in Stable, see the patch in #1

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

VladimirMarko’s picture

Status: Needs review » Reviewed & tested by the community

This patch is still working and still necessary for dropbuttons in Paragraphs.

star-szr’s picture

Started poking around this, looks like the styling in question was originally introduced in #1989470-171: Dropbutton style update for Seven before being moved to Stable.

xjm’s picture

CSS-a-licious.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs frontend framework manager review

I'm very sorry that it took so long for me to revisit this issue. Thanks @idebr for the explanation. That totally makes sense.

I think we should make a bug fix for this, but most likely it could be slightly more generic bug fix than this. The current solution only fixes the bug for input elements, but at least while reading the CSS it seems like we support button elements as well. Here's a demonstration how inconsistent the behavior of the width: auto is between these elements.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

geek-merlin’s picture

This should really be consolidated with the linked issue!

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

komalk’s picture

Status: Needs work » Needs review
StatusFileSize
new536 bytes

Patch #4 failed to apply on 9.1.
re-rolled the patch.

bandanasharma’s picture

StatusFileSize
new31.62 KB
new28.18 KB

#21 patch is apply sucessfully on 9.1.x and I have check this with paragraph module. Adding after and before screenshot. I have check on IE, Firefox and chrome, it is working fine.

bandanasharma’s picture

Status: Needs review » Reviewed & tested by the community
quietone’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for rerolling the patch and the manual testing!

Just a few more things to do here.

The patch has coding standard errors, https://www.drupal.org/pift-ci-job/1794488.

There is a request in #14 to make this fix more generic. The reroll is from a patch before that comment

Setting NW to address the above.

And let's add before and after screen shots to the issue summary. That will help reviewers.

Thanks

lauriii’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community

Thank you for the review @quietone!

I rechecked this and the bug is indeed specific to tables which is very confusing. That means, my feedback in #14 is not relevant.

The coding standard violations pointed out by DrupalCI are from CSSLint which is not used by Drupal core anymore since https://www.drupal.org/node/2868114. Moving back to RTBC

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

Hmm, probably what I was actually looking for in #14 was if we could remove this rule from core/misc/dropbutton/dropbutton.css:

.js td .dropbutton-multiple .dropbutton-action a,
.js td .dropbutton-multiple .dropbutton-action input,
.js td .dropbutton-multiple .dropbutton-action button {
  width: auto;
}

This was added in #2282599: Dropdown menus in most of core are broken in Stark but I don't think it's needed anymore.

Vidushi Mehta’s picture

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

@lauriii as per you've mentioned I've made that change.

tanubansal’s picture

StatusFileSize
new325.42 KB

Tested #27, code changes are reflecting along with FE change

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.

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.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Component: Seven theme » CSS

The Seven theme has been removed from Drupal 10 core. However, moving this to core CSS as per #26.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gaurav-mathur’s picture

Assigned: Unassigned » gaurav-mathur
gaurav-mathur’s picture

Assigned: gaurav-mathur » Unassigned
StatusFileSize
new49.41 KB

I have checked the issue without applying patch.I am not able to get the issue.
I checked this in drupal10.1.x-dev version with using seven theme.
For refer attached screenshots.

mherchel’s picture

Status: Needs review » Closed (outdated)
StatusFileSize
new468.34 KB

Verified this issue doesn't exist in 10.1.x with Claro (Seven is no longer in D10)

Closing this as outdated. Screenshot attached (note I manually modified the markup in devtools to test the CSS).