Problem/Motivation

CSS selectors from 'off-canvas.reset.css' are targetting elements in Safari and setting properties to their initial values. This is overriding styles from 'off-canvas.base.css' and causing display issues as well as making overrides difficult.

This can be seen in layout builder's off-canvas dialog. Styles are overridden such that svgs are not visible, divs with labels are the wrong color, etc. See 'safari.png'. A 1px red border was added to show elements selected in Safari.

The rule set responsible:

#drupal-off-canvas *:not(div),
#drupal-off-canvas *:not(svg *) {
  all: initial;
}

Proposed resolution

Instead of targeting all elements that should be reset with an asterisk and excluding elements that shouldn't be targeted by using a negation selector, explicitly list all elements that should be reset. This can be changed back to an asterisk after all supported browsers support CSS selectors with multiple excluded elements in the negation selector.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#137 Drupal-9.2.X.png17.97 KBkarthi5053
#127 2958588-127-backport-8.9.x.patch3.54 KBadam-delaney
#122 2021-04-23_15-51-24.png41.85 KBblainelang
#114 2021-04-03_13-37-32.png76.46 KBdanny englander
#110 2958588-110-backport-8.9.x.patch63.82 KBclayfreeman
#99 2958588 - Off-canvas style resets are overriding styles (especially SVGs) resulting in display issues.zip14.3 MBclayfreeman
#97 interdiff.txt18.42 KBlauriii
#97 2958588-97.patch100.17 KBlauriii
#93 2958588-93-89x-with-pcss.patch90.18 KBcainaru
#93 2958588-93-89x-without-pcss.patch55.21 KBcainaru
#92 2958588-92-89x-with-pcss.patch90.4 KBcainaru
#92 2958588-92-89x-without-pcss.patch55.42 KBcainaru
#91 2958588-91-92x.patch135.15 KBcainaru
#89 drupal-n2958588-89-89x.patch41.63 KBgalactus86
#88 drupal-n2958588-88-92x.patch80.8 KBdamienmckenna
#87 drupal-n2958588-86-92x.patch82.1 KBdamienmckenna
#83 IE 11 - Bartik - Layout.png89.9 KBclayfreeman
#83 IE 11 - Bartik - Block Categories.png103.43 KBclayfreeman
#83 IE 11 - Bartik - Block Options.png91.97 KBclayfreeman
#83 IE 11 - Claro - Layout.png89.01 KBclayfreeman
#83 IE 11 - Claro - Block Categories.png96.22 KBclayfreeman
#83 IE 11 - Claro - Block Options.png83.35 KBclayfreeman
#83 Edge 89 - Bartik - Layout.png553.56 KBclayfreeman
#83 Edge 89 - Bartik - Block Options.png576.31 KBclayfreeman
#83 Edge 89 - Bartik - Block Categories.png576.31 KBclayfreeman
#83 Edge 89 - Claro - Block Options.png437.7 KBclayfreeman
#83 Edge 89 - Claro - Block Categories.png644.4 KBclayfreeman
#83 Edge 89 - Claro - Layout.png452.61 KBclayfreeman
#82 Firefox - Claro - Block Options - Screen Shot 2021-03-08 at 11.41.27 AM.png621.75 KBcainaru
#82 Firefox - Claro - Block Categories - Screen Shot 2021-03-08 at 11.41.11 AM.png698 KBcainaru
#82 Firefox - Claro - Layout - Screen Shot 2021-03-08 at 11.40.59 AM.png589.73 KBcainaru
#82 Firefox - Bartik - Block Options - Screen Shot 2021-03-08 at 11.40.19 AM.png653.87 KBcainaru
#82 Firefox - Bartik - Block Categories - Screen Shot 2021-03-08 at 11.39.50 AM.png742.71 KBcainaru
#82 Firefox - Bartik - Layout - Screen Shot 2021-03-08 at 11.39.35 AM.png477.21 KBcainaru
#82 Safari - Claro - Block Options - Screen Shot 2021-03-08 at 11.33.03 AM.png505.08 KBcainaru
#82 Safari - Claro - Block Categories - Screen Shot 2021-03-08 at 11.32.48 AM.png613.48 KBcainaru
#82 Safari - Claro - Layout - Screen Shot 2021-03-08 at 11.32.35 AM.png481.52 KBcainaru
#82 Safari - Bartik - Block Options - Screen Shot 2021-03-08 at 11.31.58 AM.png586.41 KBcainaru
#82 Safari - Bartick - Block Categories - Screen Shot 2021-03-08 at 11.28.31 AM.png702.02 KBcainaru
#82 Safari - Bartik - Layout - Screen Shot 2021-03-08 at 11.28.09 AM.png581.18 KBcainaru
#82 Chrome - Claro - Block Options - Screen Shot 2021-03-08 at 11.25.42 AM.png466.38 KBcainaru
#82 Chrome - Claro - Block Categories - Screen Shot 2021-03-08 at 11.25.28 AM.png597.41 KBcainaru
#82 Chrome - Claro - Layout - Screen Shot 2021-03-08 at 11.25.04 AM.png470.24 KBcainaru
#82 Chrome - Bartik - Block Options - Screen Shot 2021-03-08 at 11.24.08 AM.png491.27 KBcainaru
#82 Chrome - Bartik - Block Categories - Screen Shot 2021-03-08 at 11.21.49 AM.png674.05 KBcainaru
#82 Chrome - Bartik - Layout - Screen Shot 2021-03-08 at 11.21.07 AM.png570.05 KBcainaru
#81 2958588-81.patch95.21 KBlauriii
#80 2958588-80.patch95.9 KBlauriii
#79 Screen Shot 2021-03-04 at 11.58.12 AM.png1.06 MBcainaru
#78 Screen Shot 2021-03-04 at 11.12.53 AM.png134.14 KBcainaru
#78 Screen Shot 2021-03-04 at 11.12.27 AM.png191.47 KBcainaru
#78 Screen Shot 2021-03-04 at 11.11.49 AM.png192.78 KBcainaru
#78 Screen Shot 2021-03-04 at 11.10.02 AM.png144.18 KBcainaru
#78 Screen Shot 2021-03-04 at 11.09.34 AM.png205.01 KBcainaru
#78 Screen Shot 2021-03-04 at 11.08.03 AM.png170.6 KBcainaru
#77 2958588-77.patch94.59 KBlauriii
#76 2958588-76.patch95.08 KBlauriii
#74 Screen Shot 2021-03-03 at 2.05.28 PM.png495.39 KBcainaru
#74 Screen Shot 2021-03-03 at 2.07.59 PM.png498.96 KBcainaru
#68 no-icons layout builder.png133.18 KBblackstallion
#68 icons appear layout builder.png136.57 KBblackstallion
#67 Screenshot 2021-02-22 at 14.42.13.png21.65 KBlauriii
#67 Screenshot 2021-02-22 at 14.41.54.png17.4 KBlauriii
#56 Selection_946.png15.13 KBlongwave
#56 Selection_945.png23.74 KBlongwave
#56 Selection_944.png49.29 KBlongwave
#56 Selection_943.png16.01 KBlongwave
#56 Selection_942.png25.94 KBlongwave
#56 Selection_941.png57.7 KBlongwave
#55 2958588-54.patch2.58 KBlongwave
#55 2958588-chrome-fixed.png27.84 KBlongwave
#55 2958588-chrome-broken.png22.08 KBlongwave
#55 2958588-firefox-fixed.png27.2 KBlongwave
#55 2958588-firefox-broken.png22.21 KBlongwave
#55 2958588-safari-fixed.png25.81 KBlongwave
#55 2958588-safari-broken.png23.24 KBlongwave
#30 off-canvas-style-resets-2958588-13.patch1.69 KBspokje
#29 off-canvas-style-resets-29586889- 20.patch.txt1.69 KBnishat ahmad
#13 off-canvas-style-resets-2958588-13.patch1.69 KBbkosborne
#11 off-canvas-style-resets-2958588-11.patch831 bytespawandubey
chrome.png213.4 KBdoublealpha
safari.png436.64 KBdoublealpha

Comments

doublealpha created an issue. See original summary.

doublealpha’s picture

Issue summary: View changes
doublealpha’s picture

Title: Off-canvas style resets are setting element properties to initial values in Safari » Off-canvas style resets are only overriding styles in Safari resulting in display issues
doublealpha’s picture

Title: Off-canvas style resets are only overriding styles in Safari resulting in display issues » Off-canvas style resets are overriding styles in Safari resulting in display issues
doublealpha’s picture

Issue summary: View changes

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.

tim.plunkett’s picture

tim.plunkett’s picture

Title: Off-canvas style resets are overriding styles in Safari resulting in display issues » Off-canvas style resets are overriding styles (especially SVGs) in Safari resulting in display issues
jmuzz’s picture

You should delete this whole rule set. Safari is the only browser actually evaluating these selectors. The other browsers do not understand a complex selector inside of :not() like :not(svg *) so they are not evaluating any of the selectors in the set.

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.

pawandubey’s picture

Status: Active » Needs review
FileSize
831 bytes

@jmuzz

You are correct and as per the analysis, I have also found the same. I have removed the whole rule set as per your suggestion.

Please verify this patch and share your feedback.

bkosborne’s picture

Status: Needs review » Reviewed & tested by the community

Ran into this as well. Note that stable theme has this CSS copied into it as well, but I guess we are not allowed to change that?

bkosborne’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.69 KB

Here is a patch that also removes the code from stable. Again, not sure on the rules surrounding that. Maybe that's not allowed?

philosurfer’s picture

#13 worked for us using core 8.7.4 and using a number of third party modules that had large images creating overflow offscreen in Safari.

artinruins’s picture

I noted these issues in a related thread (which now may be closed in favor of this one since you have a patch): https://www.drupal.org/project/foundation_layouts/issues/3037557#comment...

But yes, I can verify that the "not" selectors were written incorrectly (they should be chained together, not in two different declarations), but am wholly in favor of removing them completely as "all: initial" is a bludgeon. Working through this in a current project, we will try this patch and verify. Thanks for all your work here.

artinruins’s picture

This patch worked for me on a current Layout Builder project. Much, much better in Safari (v12.1.1 OSX 10.13.6). Drupal 8.7 project with the following dependencies in our Composer:

"composer/installers": "^1.5",
"cweagans/composer-patches": "^1.6",
"drupal-composer/drupal-scaffold": "^2.4",
"drupal-composer/preserve-paths": "^0.1.4",
"drupal/admin_toolbar": "^1.23",
"drupal/adminimal_admin_toolbar": "^1.9",
"drupal/adminimal_theme": "^1.4",
"drupal/animated_gif": "^1.1",
"drupal/backup_migrate": "4.x-dev",
"drupal/block_style_plugins": "2.x-dev",
"drupal/coder": "^8.2",
"drupal/coffee": "^1.0",
"drupal/config_installer": "^1.8",
"drupal/config_split": "^1.3",
"drupal/core": "^8.7",
"drupal/devel": "^1.2",
"drupal/draggableviews": "1.x-dev",
"drupal/entity_embed": "^1.0",
"drupal/entity_pager": "^1.0@beta",
"drupal/field_group": "3.0-rc1",
"drupal/focal_point": "^1.0",
"drupal/font_resize": "1.x-dev",
"drupal/honeypot": "^1.27",
"drupal/layout_builder_modal": "^1.0@alpha",
"drupal/layout_builder_restrictions": "^2.1",
"drupal/machine_name_widget": "^1.0",
"drupal/media_entity_browser": "^2.0",
"drupal/metatag": "^1.8",
"drupal/pathauto": "^1.3",
"drupal/recreate_block_content": "^2.0",
"drupal/responsive_favicons": "^1.5",
"drupal/role_delegation": "^1.0",
"drupal/scroll_progress": "^2.1",
"drupal/seckit": "^1.0",
"drupal/shield": "^1.2",
"drupal/token_filter": "^1.1",
"drupal/twig_field_value": "^1.2",
"drupal/view_unpublished": "1.x-dev",
"drush/drush": "^9.2",
"oomphinc/composer-installers-extender": "^1.1",
"zaporylie/composer-drupal-optimizations": "^1.0"
anybody’s picture

anybody’s picture

By the way, shouldn't we perhaps discuss the whole ID selector logic and dark background?
Wouldn't it perhaps make sense that if Drupal is "light color" based by default, to make the off-canvas grey instead of fixing a lot of single problems with the dark background? Also keeping an eye on accessibility... just my two cents.

Of course that should be a separate (META) issue.

sacarney’s picture

I tested #13 patch on our project and it works. Thank you.

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.

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.

tim.plunkett’s picture

Title: Off-canvas style resets are overriding styles (especially SVGs) in Safari resulting in display issues » Off-canvas style resets are overriding styles (especially SVGs) in Safari and Firefox resulting in display issues

Marked #3189524: Firefox 84+ has CSS issues for layout builder as a duplicate, but now this isn't just Safari

tim.plunkett’s picture

kpaxman’s picture

I can confirm that the patch in #13 does fix the issue I'm seeing in Firefox 84+

azovsky’s picture

The patch in #13 does fix the issue on Firefox 84.0.1. Thanks!

b_sharpe’s picture

Status: Needs review » Reviewed & tested by the community

Tested both Safari and FF and works as intended. The use of all is super heavy-handed in any core situation IMO.

nishat ahmad’s picture

spokje’s picture

Re-uploading patch #13, so it gets re-tested every to days against 9.2.x-dev.

At the moment the 2-daily retest is against 8.8.x-dev

mark_fullmer’s picture

For folks coming here who would prefer to avoid patching core until this is resolved, the same outcome can be achieved by using a libraries-override technique in your active theme, in the info.yml file, like so:

libraries-override:
  core/drupal.dialog.off_canvas:
    css:
      base:
        /core/themes/stable/css/core/dialog/off-canvas.reset.css: css/off-canvas.reset.css

Then put the "fixed" CSS shown in the patches above in your active theme at css/off-canvas.reset.css

jane_irwin’s picture

@mark_fullmer -- this is fantastic! Thanks for reminding us of a far more elegant (and correct!) way of handling this.

Do you know if we need to include both the reset for
/core/themes/stable/css/core/dialog/off-canvas.reset.css

as well as
/core/misc/dialog/off-canvas.reset.css.

Both are mentioned in the patch.

Thanks again for your help!

mark_fullmer’s picture

Do you know if we need to include both the reset for
/core/themes/stable/css/core/dialog/off-canvas.reset.css

as well as
/core/misc/dialog/off-canvas.reset.css.

Only the reset for the CSS file in Stable is needed (presuming you are using a theme based on stable), since Stable does its own library override of the original file: https://git.drupalcode.org/project/drupal/-/blob/9.2.x/core/themes/stabl...

This is what is meant in https://www.drupal.org/docs/theming-drupal/adding-stylesheets-css-and-ja... with the words "full path to the most recent override of that library."

jane_irwin’s picture

Thank you!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 30: off-canvas-style-resets-2958588-13.patch, failed testing. View results

longwave’s picture

Status: Needs work » Reviewed & tested by the community

Random fail, back to RTBC.

IMO this might even be "major" because the off canvas layout builder is almost unusable in Firefox and Safari without this patch.

mxh’s picture

Title: Off-canvas style resets are overriding styles (especially SVGs) in Safari and Firefox resulting in display issues » Off-canvas style resets are overriding styles (especially SVGs) in Safari, Firefox and Chromium Edge resulting in display issues

Seems I'm having the same problem (D9.1.2) at least with the SVGs, and also the font reset looks very weird, fieldset caption and detail summary formatting looks broken. Also supposedly collapsed fieldset are not collapsed etc.

It's worth mentioning that I see the display issues also appear on latest MS Chromium Edge on Windows 10.

Are the reset instructions new? Because that display problem wasn't apprent few days ago, but could be that I missed some updating progress on my local environment.

Long story short, patch from #30 solved this problem for me.

matt_paz’s picture

#30 seems to be working good for me as well.

cainaru’s picture

I might be wrong, but isn't the way to handle multiple selectors with :not() to do something like #drupal-off-canvas *:not(div):not(svg *) or #drupal-off-canvas *:not(div, svg *), otherwise the #drupal-off-canvas *:not(svg *) line immediately includes all div's again?

ref: https://developer.mozilla.org/en-US/docs/Web/CSS/:not

longwave’s picture

Re #39 there is still the issue that :not(svg *) is considered a complex selector and only supported in Safari and Firefox 84+, which is where this bug seems to come from. As per the Mozilla link "The ability to list more than one selector is experimental and not yet widely supported" and see also https://caniuse.com/css-not-sel-list

longwave’s picture

I also wondered why Chromium Edge was now seeing this bug as noted in #37. The original Chromium feature request https://bugs.chromium.org/p/chromium/issues/detail?id=580628 led me to https://bugs.chromium.org/p/chromium/issues/detail?id=1139865 which suggests this CSS feature landed in Chromium in November 2020 and is presumably coming to a stable Chrome soon as well.

cainaru’s picture

@longwave, ah that makes sense re: the complex selector!

Re: #37 We just started seeing this problem on Chrome, Firefox, and Safari today; wasn't an issue a few days ago for us either. Interestingly enough, my outdated Firefox 82.0 on my other laptop doesn't seem to experience this bug.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Did some git archaeology to help reviewers. I think we need to ascertain if this reset is doing anything useful at all before removing. The reset was added in #2826722: Add a 'fence' around settings tray with aggressive CSS reset. and then the SVG part was added in #2907420: The Off-Canvas CSS reset prevents SVGs from displaying. Specifically #drupal-off-canvas *:not(div), was added as a result of #2826722-43: Add a 'fence' around settings tray with aggressive CSS reset. so we need to repeat the earlier testing that lead to suggesting and implementing this fix.

rajab natshah’s picture

Started to get the issues this week
In Drupal 8.9.x and Drupal 9.1.x
Looks like a Browser changes
as in #41

Updating Browsers will bring up the issue
After they added the features

pcate’s picture

Started seeing this issue today as well.

rajab natshah’s picture

Priority: Normal » Critical

Tested patch #30
Thank you for the quick fix

This issue affects all old active and new built or demoing Drupal core websites.
With Layout Builder or any off-canvas used components in contrib or custom modules.

It fixes the issue in Drupal 8.9.x and Drupal 9.1.x

Not sure we should change to Reviewed & tested by the community yet.
More testing should follow for sure

Hoping to manage a fix in the current or next Drupal releases

maithili11’s picture

patch #30 work for me as well.

JohanF’s picture

Suddenly had this bug with Chrome.
Using Drupal 8.9.11(production) and 8.9.13 (test) with bootstrap_layout_builder 2.0.1

Fixed with #30 as well. Thanks

kpaxman’s picture

I suspect this will soon be a universal problem, if it isn't already, based on this Tweet I came across: https://twitter.com/LeaVerou/status/1354760561087676416

(as I understand that the current core code works when complex selectors *aren't* supported)

anthony.bouch’s picture

Also seeing this now across all browsers. The overrides also broke a layout plugin colorpicker we implemented. The patch in #13 and #30 fixes this for us as well.

PatMunits’s picture

I experience this issue in Chrome and Edge. I'm a newbie Drupal user, so I've been going crazy over this issue for the past week. I've tried installations on of a number of BS3 distros, recommended official distro, etc. I've tried building sites on Linux Mint, Ubuntu VMs, in Docker containers on Windows 10. I tried accessing these sites using different computers. Each time same result. In each case Layout Builder side panel with icons and options looks messed up. I really thought that I'm not understanding at all how to achieve a basic functionality out of Drupal if I couldn't even get installation done correctly.

I even tried a fresh basic default install of official latest distro with just Umami demo enabled. Even then I got this same exact issue with the Layout Builder. I finally went through CSS because I couldn't find whether this was a known issue or really was a problem with my inability to do a basic Drupal install. Anyhow, once "all: initial;" was checked off the side panel of Layout Builder started to look just like in demos all across the web.

This is definitely a real issue, and if it is known, and there's a work-around then it should be mentioned very clearly on the latest distro download page.

maskedjellybean’s picture

I wasn't seeing this issue on Chrome version 87.0.4280.141, but I see it after updating to 88.0.4324.96.

The patch from #30 works for me!

longwave’s picture

Title: Off-canvas style resets are overriding styles (especially SVGs) in Safari, Firefox and Chromium Edge resulting in display issues » Off-canvas style resets are overriding styles (especially SVGs) resulting in display issues

Closed #3196143: Settings tray styles broken due to off-canvas.reset.css as duplicate, noting this here as it is an extremely detailed bug report with similar findings to what has been discovered here.

Also removing the list of browsers from the issue title, now Chrome 88 is affected all major browsers are suffering from this bug.

PatMunits’s picture

Here's a set of instructions for newbies like me to get this issue fixed in production. Following these instructions will apply the patch mentioned in post #30 of this thread directly to your production server. You need to have ssh access to your server, and have composer utility available to you on that server.

1. access your server using ssh
2. navigate to the folder just above "docroot" folder of your drupal website. This is where you will find existing file named composer.json
3. open "composer.json" file in a text editor (i.e. sudo nano composer.json)
4. inside section "extra" add a new block of code (add a comma after last block before you insert new block "patches"):

    "patches": {
        "drupal/core": {
            "Off-canvas style resets": https://www.drupal.org/files/issues/2021-01-06/off-canvas-style-resets-2958588-13.patch
        }
     }

5. save file and exit
6. run command: composer install
7. run command: composer update --lock

that's it.

Instructions were figured out thanks to this post: https://www.drupal.org/forum/support/module-development-and-code-questio...

If these instructions can be improved/corrected then please help out. Thanks!

longwave’s picture

Re #43 I am not sure exactly what tests need to be repeated here, nor is it clear to me from the original comments what that was trying to solve. I think that fixing this now-critical bug (as it affects all major browsers) is preferable to looking for an edge case that may or may not still exist and we can deal with any fallout from or tweaks to this fix in a followup.

This patch is #30 with the same removed from stable9 for use in 9.x. #30 can be committed to 8.9.x.

As far as layout builder is concerned, currently in Seven the off-canvas dialog with SVGs looks horribly broken:

Safari 14:

Firefox 84:

Chrome 88:

After applying the attached patch:

Safari 14:

Firefox 84:

Chrome 88:

Note that the misaligned pencil icon is a separate issue and that should be done in a followup if it doesn't already exist.

longwave’s picture

Further before and after screenshots, all in Firefox 84:

Before:

After:

justcaldwell’s picture

While I was bumbling around researching #3196143: Settings tray styles broken due to off-canvas.reset.css, I stumbled on an article by Andy Clarke where he found that :not() doesn't work in multiple, comma-separated selectors (see "Bad Magic" heading near the end of Using multiple :not() selectors). He recommended chaining at the time (e.g. "*:not(.foo):not(.bar)) but that didn't seem to work well for this issue.

Given that most current browser versions now support multiple argument lists and complex selectors for :not() — or soon will — I decided to try that instead. So:

#drupal-off-canvas *:not(div),
#drupal-off-canvas *:not(svg *)

Becomes:

#drupal-off-canvas *:not(div, svg *)

That seemed to work well in the current version of every browser I tested (Chrome, Firefox, Edge, Safari, even IE 11!). I'm not sure it's the right solution, but, given the concerns raised in #43, it might be worth testing as a possible alternative to entirely removing the rule.

longwave’s picture

#57: that is a good point, but one thing I don't get is why does it work in IE 11?

https://caniuse.com/css-not-sel-list shows that complex :not() is only supported by 19.45% at present. Is it just that in the browsers without support, the rule is being ignored entirely? And if the rule is ignored entirely, and the off-canvas tray is working just as well without it, should we just remove the rule?

dcam’s picture

Issue tags: +Accessibility

I'm tagging this for accessibility because of the low color contrast in the section layout selection page. I've been updating sites all day to remediate this issue on U.S. Govt. websites because of that.

I'm choosing not to mark it as RTBC because I don't know if removing all of the styles might have unintended consequences. For what it's worth, I overrode the stylesheet and only removed the all: initial; property. Doing that solved the problem well enough for us.

justcaldwell’s picture

Re #58: Yeah, I think you're right. I did some more testing and he newer syntax I mentioned

#drupal-off-canvas *:not(div, svg *)

appears to only partially work in that <div>s are excluded as desired, but 'svg *' doesn't seem to do anything at all. So it's not really a viable solution. I'm guessing IE just ignores all of it (which is why it seems to work there?).

rajab natshah’s picture

Thank you, Dave for #55

Needed for when the Layout Builder was released in Drupal core in a number of older versions too.

Is it right to have Browser version media selections or an extra library switcher for old and new browsers?

Like @supports or not supported

pbone3b’s picture

Patch #30 with the help of #54 worked for me.
Running 8.8.11
Thanks!

luke.leber’s picture

I can confirm patch #30 seems to work - we're running 8.9.13.

I'm in agreement with #55 - this issue can make Layout Builder a hard sell in today's competitive market.

Thanks!

chike’s picture

#13 worked for me using 8.9.13 (guess it's same as #30) and now I find I have to make this patch in all my sites using LB as all are having this issue. I use Chrome.

I think this should be considered as critical and get committed 'cos it would be giving lots of people a bad experience with LB.

freddy rodriguez’s picture

off-canvas-style-resets-2958588-13.patch: Tested in 9.1.4 core with Google Chrome Versión 88.0.4324.150

Works great.

karlshea’s picture

Status: Needs review » Reviewed & tested by the community

I can't imagine what unintended consequence would be worse than the whole sidebar being broken.

lauriii’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
FileSize
17.4 KB
21.65 KB

I don't think it's feasible to remove the fence altogether because that increases the chance of styles leaking to the off-canvas. For example, I tested this using Layout Builder and Claro and I can see that the Claro form styles are leaking to the off-canvas after this change:

Here's how that looks before the patch:

blackstallion’s picture

Solved by commenting out all: initial at

#drupal-off-canvas *:not(div), #drupal-off-canvas *:not(svg *), #drupal-off-canvas *:after, #drupal-off-canvas *:before {
    /* all: initial; */
    box-sizing: border-box;
    text-shadow: none;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: initial;

Screenshots attached.
OS: Windows 10 Google Chrome: Version 88.0.4324.190 (Official Build) (64-bit)
Drupal: 8.9.13 and 9.1.4 (Having this issue in both)
Screenshot icons not appearing
 Icons appearing

nwom’s picture

Re-showing most recent patch that was most likely accidentally hidden by Blackstallion

clayfreeman’s picture

Status: Needs work » Reviewed & tested by the community

The concern raised in #67 seems moot (for now); the off-canvas styling in question wasn't even being applied in the last "known-good" versions of browsers.

I vote we just remove it until a decision can be reached about the proper way to handle the styling reset that #2826722: Add a 'fence' around settings tray with aggressive CSS reset. was trying to address; I'd much rather have this working the way that it was previously (i.e., without the broken styling reset) than have it in its current broken state.

RTBC +1 #55 and hard agree with #66.

timme77’s picture

#31 worked for me with this code in my info.yml file. Thx!

libraries-override:
    core/drupal.dialog.off_canvas:
      css:
        base:
          misc/dialog/off-canvas.reset.css: css/theme/off-canvas.reset.css
azinck’s picture

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work

Resetting status per the review from the front-end framework manager in #67. I'm not sure what you mean in #70 about it being moot, @lauriii attached screenshots that show a regression.

Maybe we'll end up going forward with this as-is, but it's worth discussion.

cainaru’s picture

I noticed the same style bleeding from Claro into the off-canvas sidebar as #67's screenshot, but in an older version of Chrome (prior to Version 88.0.4324.96) without any of the patches from this issue (I wanted to see what the off-canvas sidebar was meant to look like).

Perhaps that is what #70 is referring to by the following statement; that the fence wasn't preventing style leakage in older/"last known-good" browsers as intended?

the off-canvas styling in question wasn't even being applied in the last "known-good" versions of browsers

To reproduce:

  1. Follow these instructions from the Chromium Project to grab an older version in which the off-canvas sidebar looked not broken (e.g., Version 87.0.4280.0 in my case)
  2. Spin up a sandbox on simplytest.me
  3. Enable Layout Builder and Layout Discovery
  4. Go to /admin/structure/types/manage/page/display/default and check the box Use Layout Builder
  5. Click Manage Layout button
  6. Click Add block in a section
  7. Make note of the appearance of the off-canvas sidebar
  8. Go to /admin/appearance and install Claro and set Claro to the default theme
  9. Go back to /admin/structure/types/manage/page/display/default/layout and click Add block in a section
  10. Make note of the appearance of the off-canvas sidebar

In step 7, the off-canvas sidebar looked as anticipated (see screenshot 1) whereas in step 10 the styling from Claro bleeds into the off-canvas sidebar (see screenshot 2).

Screenshot 1:
Off-canvas sidebar open in layout builder on a basic page using Bartik

Screenshot 2:
Off-canvas sidebar open in layout builder on a basic page using Claro

I haven't gotten a chance yet to figure out how to get old versions of Firefox/Safari/IE yet and repeat these steps there, but figured maybe this information might help add to the discussion regarding the fence?

clayfreeman’s picture

Status: Needs work » Needs review

@tim.plunkett

#74 is exactly right; the leaks from Claro were always happening, even after #2826722: Add a 'fence' around settings tray with aggressive CSS reset. was committed. This is because browsers were ignoring the style reset introduced in that issue. Had browsers actually been applying the styles introduced in that issue at the time, it would have never been committed as-is because the proposed style reset was arguably bad code.

Now that browsers are paying attention to the style reset introduced in that issue, Layout Builder is practically unusable in updated browsers. The style reset introduced in #2826722: Add a 'fence' around settings tray with aggressive CSS reset. is the root cause of the regression described by this issue; it should be reverted so that we're not busy engaging in a philosophical discussion while Layout Builder remains broken.

Waiting for a perfect solution, in this case, is definitely the enemy of the good.

lauriii’s picture

Issue tags: +Needs manual testing
FileSize
95.08 KB

I tried to come up with a solution that would allow us to retain the CSS reset and fix the bug. I could use some help on testing this approach manually.

lauriii’s picture

FileSize
94.59 KB

Rerolled to latest 9.2.x.

cainaru’s picture

Tested the patch from #77 in Chrome Version 88.0.4324.192.

Definitely looks much better now, yay! However, a couple of minor things I noticed:

  • The cursor isn't a pointer hovering over links (unfortunately I couldn't capture this in my screenshots :( ). This was evident with both Bartik and Claro as the default theme.
  • When the default theme was set to Claro, the dropdown arrow on the block categories was missing. Compare Screenshot 2 to Screenshot 5 (very minor, but figured I'd mention).
  • There is some slight styling leakage from Claro with regards to input sizing and some input positioning (e.g., the checkbox and dropdown select list on the Body field block in Screenshot 3 compared to Screenshot 6).

Again, these are probably pretty minor and probably aren't showstoppers for getting some sort of fix in so Layout Builder is usable for folks, but figured these were worth noting.

My testing steps, for anyone else who has availability to test in IE/Firefox/Safari:

  1. Spin up a sandbox on simplytest.me on 9.2.x with the patch from #77
  2. Enable Layout Builder and Layout Discovery
  3. Go to /admin/structure/types/manage/page/display/default and check the box Use Layout Builder
  4. Click Manage Layout button
  5. Click Add section
  6. Make note of the appearance of the off-canvas sidebar
  7. Click Add block in your new section
  8. Make note of the appearance of the off-canvas sidebar
  9. Go to /admin/appearance and install Claro and set Claro to the default theme
  10. Go back to /admin/structure/types/manage/page/display/default/layout and click Add section
  11. Click Add block in your new section
  12. Make note of the appearance of the off-canvas sidebar

Screenshot 1:
Off-canvas sidebar open in layout builder on a basic page with layout section options using Bartik

Screenshot 2:
Off-canvas sidebar open in layout builder on a basic page using Bartik, showing block categories

Screenshot 3:
Off-canvas sidebar open in layout builder on a basic page using Bartik, showing options for a field block

Screenshot 4:
Off-canvas sidebar open in layout builder on a basic page with layout options using Claro

Screenshot 5:
Off-canvas sidebar open in layout builder on a basic page using Claro, showing block categories

Screenshot 6:
Off-canvas sidebar open in layout builder on a basic page using Claro, showing field block options

cainaru’s picture

Oh, one more note from testing #77: it doesn't look like there is a visual indicator for required fields in the off-canvas sidebar (at lease in Chrome Version 88.0.4324.192). The title field is required, but there isn't the little red asterisk next to it to signify that it is required. See screenshot below:

Off-canvas sidebar open in layout builder on a basic page using Bartik, showing options for a field block. Note that the Title field is required but there is no visual indicator signifying that.

This might be unrelated to this issue though; I think I noticed its absence several months ago on a project.

lauriii’s picture

Issue tags: +Needs followup
FileSize
95.9 KB

Thank you for the extremely thorough manual testing and documenting the steps used for testing! That is very helpful! 💯

This should address #78.1. Unfortunately I was unable to create interdiff because git is going haywire with the file copies.

The issues with Claro styles leaking are pre-existing. We should look into those in a separate issue.

I also tested #79 manually and it also seems like a pre-existing problem which should receive it's own issue.

lauriii’s picture

FileSize
95.21 KB

The previous patch is going to fail stylelint 🤦‍♂️

cainaru’s picture

FileSize
570.05 KB
674.05 KB
491.27 KB
470.24 KB
597.41 KB
466.38 KB
581.18 KB
702.02 KB
586.41 KB
481.52 KB
613.48 KB
505.08 KB
477.21 KB
742.71 KB
653.87 KB
589.73 KB
698 KB
621.75 KB

Tested the patch from #81 in Chrome 89.0.4389.82, Safari 14.0.3, and Firefox 86.0 (64-bit).

Looks good!!! 🙂I've attached screenshots in case anyone wants to verify or noticed something off. Only note is in Firefox: in my last screenshot, the select list dropdown arrows seem a bit misshapen from bleeding from Claro (but again, makes more sense for a followup).

Still need someone to test in Microsoft Edge and/or Internet Explorer.

My testing steps, for anyone else who has availability to test in Microsoft Edge and/or Internet Explorer:

  1. Spin up a sandbox on simplytest.me on 9.2.x with the patch from #81
  2. Enable Layout Builder and Layout Discovery
  3. Go to /admin/structure/types/manage/page/display/default and check the box Use Layout Builder
  4. Click Manage Layout button
  5. Click Add section
  6. Make note of the appearance of the off-canvas sidebar
  7. Click Add block in your new section
  8. Make note of the appearance of the off-canvas sidebar
  9. Go to /admin/appearance and install Claro and set Claro to the default theme
  10. Go back to /admin/structure/types/manage/page/display/default/layout and click Add section
  11. Click Add block in your new section
  12. Make note of the appearance of the off-canvas sidebar
  13. Repeat Steps 4-12 for the latest versions of each browser.
clayfreeman’s picture

cainaru’s picture

@clayfreeman, yay thank you for testing in Edge 89 / IE 11! 🎉

Just to make sure I'm not misunderstanding, when you said the following in #83:

I think we'll probably need to work something out for the select box styling because of possible A11Y concerns

You are referring to the select box styling issue in the screenshot of IE 11 and Claro (specifically https://www.drupal.org/files/issues/2021-03-09/IE%2011%20-%20Claro%20-%20Block%20Options.png), right?

Other than that issue, so far it looks pretty good in Edge 89 / IE 11!

clayfreeman’s picture

That is correct - I don't see how we'd get A11Y sign-off without an indicator on select boxes.

galactus86’s picture

I tried the patch on #81 but it failed since I am on Drupal core 8.9. Is there a version that isn't for D9 yet?

damienmckenna’s picture

Status: Needs work » Needs review
FileSize
82.1 KB

Rerolled.

damienmckenna’s picture

Rerolled again? Sorry, I'm new to working with the PostCSS-based codebase.

galactus86’s picture

FileSize
41.63 KB

Tried to reroll against 8.9.x
My first time rolling a patch that modifies .css

cainaru’s picture

@clayfreeman -- figured out what's causing the select arrows to disappear when using Claro: it's this line here in Claro.

I'm wondering if adding the following to /core/misc/dialog/off-canvas.base.pcss.css, core/themes/stable/css/core/dialog/off-canvas.base.pcss.css, and core/themes/stable9/css/core/dialog/off-canvas.base.pcss.css might be a good safeguard in case other contrib themes do the same?

#drupal-off-canvas select::-ms-expand {
  display: block;
}
cainaru’s picture

FileSize
135.15 KB

My attempt to re-roll the patch from #81 for 9.2.x with the suggestion from #90 for select buttons in IE.

Unfortunately having a bit of a rough time getting started out with PostCSS and my git diff is going haywire as well, so I'm hoping this patch has everything from #81.

cainaru’s picture

Here are two re-rolls of #91, but for 8.9.x.

The first patch includes the respective CSS and the .stylelintignore changes without PostCSS, and the second patch includes those changes with PostCSS (I was not sure if we are using PostCSS in 8.9.x, hence creating both patches just in case).

I haven't manually tested either of these yet.

cainaru’s picture

FileSize
55.21 KB
90.18 KB

Realized one of the files in #92 was missing a couple of styles 🤦‍♀️

Anywho, re-rolled for 8.9.x -- first one is without the .pcss.css files, and the second one includes .pcss.css files.

lauriii’s picture

Issue tags: -Needs followup

I think we should address the bug with the Claro select element in a follow-up issue: #3204104: Claro styles leaking to off-canvas.

clayfreeman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs manual testing

In that case, RTBC for #81 from me.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

One small docs request before that (and an issue summary update), but otherwise I agree on RTBC.

Also from now until this is committed, please stop posting 8.9 backports. It will only confuse the testbot.

  1. +++ b/core/misc/dialog/off-canvas.base.pcss.css
    @@ -4,16 +4,101 @@
    +#drupal-off-canvas {
    

    This is a long list of elements. Can a comment here mention which ones are excluded from the list? (div and span, from what I can see)

  2. +++ b/core/themes/stable/css/core/dialog/off-canvas.base.css
    @@ -44,87 +140,105 @@
    -  margin: 10px 0;
    +  margin: 0.625rem 0;
    

    Are all these changes because of a change to our compiling rules? Or were they manual changes from another issue incorrectly made to the generated CSS that need to be reflected in the pcss?

lauriii’s picture

Status: Needs work » Needs review
FileSize
100.17 KB
18.42 KB

Added comment. I had to double check the list again to remember all elements that I had excluded and I noticed I had missed few elements that probably should be on the list. Here's an updated patch with those elements added, as well as comment explaining where the list of elements has been taken and which elements were excluded.

The changes from px to rem are caused by PostCSS px to rem plugin which we have enabled #3117698: Allow PostCSS Plugin “Px to Rem” in core for Olivero theme.

clayfreeman’s picture

Assigned: Unassigned » clayfreeman

Working on updating the manual testing screenshots. Will update soon.

clayfreeman’s picture

Here's a ZIP file of all the browsers' screenshots. I'll note that there doesn't appear to be any regression & there was actually an improvement: #85 is fixed!

Pending testbot, this is RTBC from me.

clayfreeman’s picture

Assigned: clayfreeman » Unassigned
johnpitcairn’s picture

FWIW, if you're needing to quick-fix this right now, the patch in #13 does not include the Stable9 theme, and won't work for any themes using that as a base theme. Also note the most recent patch at #97 will not apply to 9.1.x. The best approach in this case will be to apply the libraries-override fix as per #31, but use /core/themes/stable9/css/core/dialog/off-canvas.reset.css as the overridden path.

alexpott’s picture

We still need an issue summary update as per #96. I was wondering if we needed a change record but I've checked Bootstrap and a few other usual candidates and no one is overriding the core implementation so I don't think a CR is necessary.

lauriii’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

The implementation does have a slight change on the weight because we're changing from asterisk to a specific elements. The use cases that I could think of where this could cause issues are if someone is providing off-canvas specific CSS targeting element types and it's loaded before the reset, and also if someone is doing off-canvas specific reset overrides using an asterisk as a selector. These both seem rare edge cases so it would probably be just noise to post a CR for this.

justcaldwell’s picture

Not sure if one example merits a CR, but Bootstrap Styles comes to mind as a project that does extensive off-canvas styling. Seems like their light and dark theme css both do some off-canvas reset overriding, around line 1147 e.g.:

#drupal-off-canvas *,
#drupal-off-canvas *:not(div) {
  color: #383A40;
  background: unset;
  font-family: inherit;
}
alexpott’s picture

Working on updating issue credit. In addition to people already creditted:

  • Credited @galactus86 for supplying a patch
  • Credited @tim.plunkett, @justcaldwell for reviews
  • Credited @mark_fullmer for supplying a useful workaround
lauriii’s picture

I actually found out that CSS is smart and adds weight for the element type even though it's defined in :not(). Therefore, the current solution doesn't change the weight at all. Here's an excellent blog post about this: https://bitsofco.de/on-not-and-specificity/.

I also tested Bootstrap Styles manually to confirm that this change doesn't have an impact at least on the rule mentioned in #104.

alexpott’s picture

Version: 9.2.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed and pushed 2fccc04de4 to 9.2.x and 7e6c791fdd to 9.1.x. Thanks!

I think we should consider backporting this to 8.9.x

  • alexpott committed 2fccc04 on 9.2.x
    Issue #2958588 by cainaru, lauriii, DamienMcKenna, longwave, galactus86...

  • alexpott committed 7e6c791 on 9.1.x
    Issue #2958588 by cainaru, lauriii, DamienMcKenna, longwave, galactus86...
clayfreeman’s picture

Here's my attempt at a backport patch to Drupal 8.

clayfreeman’s picture

Status: Patch (to be ported) » Needs review
jeremyvii’s picture

Status: Needs review » Reviewed & tested by the community

The 8.9.x backport LGTM. Tested in Chrome, Firefox, Edge, and IE 11.

SaraT’s picture

@clayfreeman I am on 8.9.13 and tried applying patch #110, but it could not apply patch. I've no idea how to tell what the problem was, because it just restates that in the exception. I'm not a developer. I just pretend to be one for my library. I could have missed something important, but I've successfully installed module patches using Composer, so I pretty much followed the same process for this.

danny englander’s picture

FileSize
76.46 KB

Just noting that I'm on Drupal 9.1 and the patch from #93 worked for me.

Icons, drupal 9.1

c. s. comfort’s picture

I'm on 8.9.13 and trying to implement the libraries override method in #31. However, the override stylesheet fails to load. I've verified that the stylesheet is reachable in its expected location /themes/custom/utni/dist/css/off-canvas.reset.css and that the Drupal cache has been cleared -- to no avail. Other overrides, such as system/base, do function as expected.

libraries-override:
  system/base: false
  views/views.module: false
  core/drupal.dialog.off_canvas:
    css:
      base:
        /core/themes/stable/css/core/dialog/off-canvas.reset.css: dist/css/off-canvas.reset.css

Am I overlooking something obvious?

alexpott’s picture

@C. S. Comfort - is your theme using stable as a base theme? If not then the override would be:

libraries-override:
  system/base: false
  views/views.module: false
  core/drupal.dialog.off_canvas:
    css:
      base:
        /core/misc/dialog/off-canvas.reset.css: dist/css/off-canvas.reset.css

I think...

An alternative solution would be to use composer-patches and apply the patch in #110.

alexpott’s picture

komlenic’s picture

+1 for the 8.9.x backport in #110

lauriii’s picture

Tested #110 manually on Simplytest.me and it seemed to work as expected. +1 for backport.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e2e6d50 and pushed to 8.9.x. Thanks!

  • alexpott committed e2e6d50 on 8.9.x
    Issue #2958588 by cainaru, lauriii, DamienMcKenna, clayfreeman, longwave...
blainelang’s picture

FileSize
41.85 KB

Just updated from 9.1.5 to 9.1.7 and had been using the patch in #13. After updating to 9.1.7 I assumed the patch was not necessary so I removed it - but the issue came back. It makes using Layout Builder for our clients pretty frustrating.

We are using Bootstrap Layout Builder with a Bootstrap 4 subtheme.

off-canvas-issue

Tried patches 13, 81 and 97 and all fail to apply.

I was successful in using the libraries-override as per Mark Fullmer in #31 and that cleared up the issue.

SaraT’s picture

We updated to 8.9.14 thinking this would be fixed, but there was no visible change when I went to use Layout Builder on a page. I'm not a developer, so I may have misunderstood. Do we have to change to a different 8.9? Thanks!

Webbeh’s picture

Per #123, 8.9.14 looks to only contain the security fix per the release notes.

tim.plunkett’s picture

Status: Fixed » Needs work
Issue tags: +Needs change record, +Needs release note, +9.2.0 release notes

This is a relatively big change that shouldn't break anything, but is worth calling out for custom themes.
Reopening for a change record and a release note snippet.

mahmoud-zayed’s picture

We have a ticket to track the impact of the latest changes and apply it to Bootstrap Layout Builder:
https://www.drupal.org/project/bootstrap_styles/issues/3211154

adam-delaney’s picture

Attempt to re-rolled 110 against latest 8.9.x branch

adam-delaney’s picture

I see that this was committed already.

Webbeh’s picture

#127 does not apply cleanly, and appears to be a diff between another patch, given the file size discrepancy between itself and #2958588-110: Off-canvas style resets are overriding styles (especially SVGs) resulting in display issues.

Per #130, this doesn't need a reroll for the latest 8.9.x release, thank you for the quick response!

longwave’s picture

There is no reroll needed, this was already committed to 8.9.x in #121.

This issue is only "needs work" for the change record and release note.

clayfreeman’s picture

Status: Needs work » Fixed
Issue tags: -Needs change record, -Needs release note

CR added here: https://www.drupal.org/node/3212880

Release note snippet below:

Prior to this release, off-canvas styles were reset by using an asterisk CSS selector and excluding elements that shouldn't be targeted by using a negation selector. The strategy in this release has changed such that all elements that need to be targeted are explicitly listed instead of using an asterisk selector. See this change record for more information: https://www.drupal.org/node/3212880

Status: Fixed » Closed (fixed)

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

chi’s picture

CR added here: https://www.drupal.org/node/3212880

Any reason it's not published yet?

chi’s picture

longwave’s picture

Published the change record.

karthi5053’s picture

Having issues in Drupal 9.2.x.

karthi5053’s picture

FileSize
17.97 KB
stuckinconcretejungle’s picture

A few days ago, we have upgraded to 9.2.x and non of the patches were successfully applied. But following Mark Fullmer's suggestion in #32, I was able to temporary have a solution till a patch for 9.2.x actually comes out.

Or maybe this solution is good enough till core has an update.

pcate’s picture

@bowiechang the patch for this issue has already been merged into 9.1 and 9.2, so you no longer need to use a patch.

hlopes’s picture

Doing some shenanigans with Sortable js + off_canvas, and that all: initial makes it impossible to drag from off_canvas

anybody’s picture

FYI: Added a feature-request to provide a class to opt-out from reset in contrib, if needed: https://www.drupal.org/project/drupal/issues/3395617