Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
ckeditor5.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Nov 2021 at 13:59 UTC
Updated:
27 Jul 2023 at 06:43 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersComment #3
wim leersComment #5
nod_I think the "formal" solution will be possible with CSS cascade layers (see https://www.w3.org/2021/10/TPAC/demos/css-architecture.html and https://www.bram.us/2021/09/15/the-future-of-css-cascade-layers-css-at-l...)
If layers are available, it also mean no shadow dom necessary for things like #2195695: Admin UIs on the front-end are difficult to theme
Comment #6
wim leersTIL cascade layers 😮
Not yet widely available though: https://caniuse.com/css-cascade-layers. Only next versions of Chrome, Firefox and Safari, i.e. 0.1% of today's browser usage 😬
Comment #7
nod_In the current code the styles reset result change depending on aggregation being activated or not.
When CSS aggregation is ON, there are 0 rules ignored.
When CSS aggregation is OFF, 237 rules from those css files are ignored:
Comment #8
wim leersI … am not sure I fully understand that. Are you saying you found a bug in HEAD?
Comment #9
nod_I guess, but it's not really important since the extra 200 rules generated will never match anything it turns
#drupal-off-canvas *into#drupal-off-canvas [data-drupal-ck-style-fence] #drupal-off-canvas *.Got a better solution using donut selectors: https://css-tricks.com/weekly-platform-news-focus-rings-donut-scope-ditc...
Comment #11
wim leersYou keep throwing new terms at me — this time 🤪
Also: wow, that looks super interesting.
I looked at the MR, and I think @bnjmnm would be a far better reviewer than I possibly could be. He has recent/prior experience in this area, I don't. To me, what jumps out, are coding standards nitpicks (incomplete JS docblocks).
Comment #12
nod_Also previous code seems like it doesn't work for rules inside media queries or rtl styles (that have
[dir=rtl] #drupal-off-canvasfor example)Comment #13
wim leersThat seems like a pretty significant bug.
Which begs the question … are we missing test coverage? 😬 (That sounds like no fun to write test coverage for, and I'm not sure it's worth it, but I have no choice but to ask.)
Comment #14
lauriiiI'm wondering if we should work on this here, but here's an example of something that should work. The link in this image should be rendered as blue according to CKEditor CSS. However, it is overridden by the off-canvas reset.

This is already broken but it's broken differently than after the patch. I'm wondering if we'd prefer to work on this here or should it be separate issue? I'm not sure what would be a better use case to test this.
Comment #15
nod_For the tests it's the css that will be annoying to write. Should be easy enough overall though.
i do think we should at least find the cause of those issues and add a few comment in the code in this issue, even if we don't solve everything.
Comment #16
longwaveDoes the "donut scope" selector work in IE11? We had issues with complex
:not()before, see #2958588: Off-canvas style resets are overriding styles (especially SVGs) resulting in display issues and https://caniuse.com/css-not-sel-listIf it doesn't, this will have to be Drupal 10 only.
Comment #17
nod_good question, not sure if
[attr] *is considered a selector list (probably i'd say).As far as core support goes, it's experimental in 9.4 so we might get away with it? no issue for D10 though, that's good. Can't be a generic solution but can be suitable for CKE depending on the answer to getting away with it in experimental
Comment #18
lauriiiWe have to get CKEditor 5 stable in Drupal 9.4.0 to provide replacement for CKEditor 4 before Drupal 10 ships. However, since CKEditor 5 is not supporting IE 11 at all, we could ignore that aspect.
Comment #19
nod_So during testing we can see that the previous code was working and it worked because of the increased specificity of the cke selectors
it turned
.cke.cke-contentinto#drupal-off-canvas [data-drupal-ck-style-fence] .cke.cke-contentmaking that rule apply above all the others. It also turns@media screen, print {}into#drupal-off-canvas [data-drupal-ck-style-fence] @media screen, #drupal-off-canvas [data-drupal-ck-style-fence] print {}, the rule is invalid and gets ignored so no harm. We could avoid the unnecessary work though.With the patch the styles are not applied and there is nothing to override. It doesn't break media queries or nested media, supports declarations.
I don't have a failing test though.
Comment #20
nod_Tests work locally with chrome 97 and in core we have chrome 87, which doesn't support the selector: https://caniuse.com/css-not-sel-list
Comment #21
wim leersWe should update core. Chrome 87 is from November 2020: https://developer.chrome.com/blog/new-in-chrome-87/.
Per https://caniuse.com/usage-table, a tiny fraction uses Chrome 87.
Also, per
core/package.json:But, important to ask: which is the first version of Chrome that supports this selector?
Comment #22
nod_version 88 :D
Comment #23
wim leersThat seems … reasonable :D
Comment #24
wim leersI think we need a follow-up issue that is postponed on #3258114: Upgrade Chromedriver (thanks for that!) to bring back the extra tests?
Comment #25
nod_going to post the tests in #3259769: Add tests for CKEditor 5 off-canvas CSS reset
Comment #26
wim leers👍
I don't think I'm eligible to RTBC this, so keeping at — I've done all I can to push this one forward 😊
Comment #27
nod_Added more comments. I'm really not sure how best to explain it :/ let me know if that helps.
Comment #28
lauriiiIt seems like the insert before and after styles would be broken by this change:

Comment #29
nod_one more thing that the script does, duplicate all
.ck*css rules and prefix them with#drupal-off-canvas [data-drupal-ck-style-fence].Before
After
Comment #30
lauriiiMade minor improvements to the docs. Other than that this is now working as expected and this is still an optimized version of the previous script since this doesn't require duplicating all CSS from the page.
Comment #31
wim leers2 random fails in media tests — re-testing.
Comment #32
lauriiiHere's Drupal 10 patch of the MR.
Comment #34
bnjmnmBack to NW for docs-related things and to confirm one still-open @lauriii thread is addressed. Overall a very nice solution.
Comment #35
lauriiiI improved some of the documentation and confirmed that my feedback was addressed.
Comment #36
bnjmnmChanges look good. Could we get a Drupal 10 patch of the current MR?
Comment #37
lauriiiComment #39
bnjmnmCommitted to 10.0.x, waiting for rebase to pass to merge MR to 9.4.x. Very elegant optimization!
Comment #41
bnjmnmComment #42
bnjmnmThis is probably a good candidate for 9.3 as CKEDitor 5 is experimental and the change is non disruptive. Will check with @lauriii before making it official, though.
Comment #43
wim leers+1
Comment #45
bnjmnmCherry picked to 9.3.x
Comment #47
murphyw commented