Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We're using Layout Builder to allow editors to add custom blocks to a page. One of our custom blocks has a multi-value term reference field on it, with the form widget rendered as a combobox (multi-select). In Chrome, the list items "escape" the bounding box and overflow vertically.
Screenshot of what it should look like (Seen in Safari/Firefox/Edge):
Here's what it actually looks like in Chrome:
Steps to reproduce:
- Install fresh site from 8.6.x or 8.7.x and use "Standard" profile
- Enable Layout Builder
- Add at least 5 terms to the existing "Tags" vocabulary
- Add a custom block type and add a term reference field to the tags vocabulary. Allow unlimited items
- Update form display widget for that block type to use a select list
- Enable layout builder for the existing "Basic Page" content type default entity view display
- Edit layout, add block, and select "Add Custom Block"
- Add the new block you created, and observe the issue
This seems to be related to the "-webkit-appearance: menulist;" CSS property that's added in off-canvas.form.css. Once I removed that, it looks like it does in FireFox and Safari.
Comments
Comment #2
bkosborneComment #3
bkosborneComment #4
bkosborneNot sure, but I think this should be CSS component and not settings tray.
Comment #5
AaronMcHaleAdding Edge to the list along with Sarari and Firefox where this doesn't break, as confirmed this bug is not there in Edge.
Comment #6
AaronMcHaleBumping version to 8.8.x, might also be able to back-port to 8.7 if a patch passes before 8.8 release.
Comment #7
tdroden CreditAttribution: tdroden at University of Calgary commentedWe've recently run into this, and I believe I have a simple patch for it, but would need to be applied against
web/core/misc/dialog/off-canvas.form.css
&/orweb/core/themes/stable/css/core/dialog/off-canvas.form.css
. I'm not sure which, or is it both CSS files? Any insight would be greatly appreciated.Comment #8
bkosborneFrom what I understand, the stable theme is never supposed to change existing rules like that (to prevent surprises from themes that extend from it). But it would certainly need to be updated in the web/core/misc/dialog/off-canvas.form.css file.
Comment #9
mgbauman CreditAttribution: mgbauman commentedI think changing the selector to not include multiselects in web/core/themes/stable/css/core/dialog/off-canvas.form.css will work. That way, regular selects will still get -webkit-appearance: menulist; and -moz-appearance: menulist; but multiselects will not.
Comment #10
mgbauman CreditAttribution: mgbauman commentedComment #12
AaronMcHaleAlright, let's see if we can get this tiny but useful fix into 8.8 at the very last second :D
Patch adds the fixed CSS to
core/misc/dialog/off-canvas.form.css
as well ascore/themes/stable/css/core/dialog/off-canvas.form.css
.Also for the record, there was a brief discussion in Slack involving myself, benjifisher, dww, webchick and lauriii about this issue, and there seemed to be consensus that it should be fine to make this change in stable because it's a bug fix, it's a very small change, and it only impacts the off canvas dialogue / settings tray, so it's very unlikely that a theme would have customised this. It's also worth noting that #2659890: [Policy] [Plan] Drupal 9 and 10 markup and CSS backwards compatibility is trying to solve the dilemma of when and where it's ok to make CSS changes.
Comment #13
AaronMcHaleStarted on a CR, but will have to finish it later today as need to for now. https://www.drupal.org/node/3096346
Comment #14
bkosborneAre we sure that [multiple="multiple"] is needed and not just [multiple]? I've been using a version of this patch that just targets [multiple] and it's fine
Comment #15
AaronMcHaleWell spotted @bkosborne, according to W3Schools the multiple attribute doesn't take any value: https://www.w3schools.com/tags/att_select_multiple.asp. Uploaded a new patch and interdiff.
Comment #16
AaronMcHaleAdded a description of the change (along with the screenshots in the IS) to the draft change record at https://www.drupal.org/node/3096346
Comment #17
lauriiiShould we open a follow-up to come up with a better design for the multi-select list? This issue at least makes the element usable on Chrome which is a big step forward! 👏
Comment #18
AaronMcHaleYes that sounds like a good idea, for example the big white border as it is now isn't really consistent with the off canvas / settings tray look, opened #3096861: Improve the design/UX of multi-value select elements in Off Canvas Dialogue forms as a follow-up.
Comment #19
lauriiiAwesome! Let's get this done first.
I think this change to Stable is fine. It does increase the specificity of the selector but the selector is only using
-webkit-appearance
and-moz-appearance
properties so it seems something that would have just a small risk of colliding with something else.Comment #20
AaronMcHaleBetter title.
Comment #21
alexpottCommitted and pushed c9af9e0fdb to 9.0.x and 2d5621de71 to 8.9.x. Thanks!
Gonna ping @lauriii about backporting this.
Comment #24
alexpott@lauriii and I agreed to backport this to 8.8.x. I can't really imagine what this is going to break in a worse than HEAD is already broken.
Comment #27
Chris Burge CreditAttribution: Chris Burge at University of Nebraska commentedGood work on fixing the spillover issue. I wish I'd found this issue when I opened #3080698: Multiple select element is inappropriately targeted with CSS in settings tray in Sept. 2019. We still have an issue with color and background-color for
<option>
in multiple select elements.How it looks:
How it should look:
Patch needs reviewed at #3080698: Multiple select element is inappropriately targeted with CSS in settings tray.