CKEditor 5 has its own focus styles, should use the admin theme's

Created on 30 March 2022, over 2 years ago
Updated 23 January 2023, almost 2 years ago

Problem/Motivation

If I tab into a CKeditor 5 body field the focus outline is in a light blue instead of the expected green. The blueish outline fails SC 1.4.11 and SC 2.4.7 (Unable to find the exact hex value for the blueish outline in the devtools but definitely less. with the color picker i got something around #8AAFEC which leads to a contrast of 2.2:1 tops without any padding in between the field and the outline also)

CKEditor 4

CKeditor 5

the really odd part is if i go into the devtools and trigger the focus state for the element i am able to get the expected green outline.

on the other hand i am unable to trigger the blue outline manually. tested on safari 13.1.2 and the latest firefox.

Steps to reproduce

- Go to /node/add/page or /node/add/article
- First select a CKEditor 4 text format
- tab until you reach the body field -> you should see the green outline around toolbar and body field
- Switch to CKEditor 5 text format
- tab until you reach the body field -> you should see a blueish outline around just the body field
- go to the devtools and find the div with the ck-editor__main class and manually trigger the focus state for the ckedtior5 body field -> you should see the green focus outline

I've set the component to Claro but I suppose it MIGHT be directly CKEditor5 related cuz I remember there was an issue moving the scope of the outline from toolbar+body field to body field only. If so please move the issue over to the CKEditor 5 component.

๐Ÿ“Œ Task
Status

Active

Version

10.1 โœจ

Component
CKEditor 5ย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • CSS

    It involves the content or handling of Cascading Style Sheets.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mgifford Ottawa, Ontario

    So CKEditor's styles. Do they meet the color contrast requirements? Is it just that they look different, or can't be easily updated? Consistency is definitely a plus for usability. What WCAG SC would it lie under?

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #20: @bnjmnm is a (provisional) accessibility maintainer of Drupal core (just like you!) and he reviewed CKEditor 5's accessibility in detail, and specifically reviewed it for regressions compared to CKEditor 4. Hence also his detailed comment at #6.

    On the roadmap issue ( #3238333: Roadmap to CKEditor 5 stable in Drupal 9 โ†’ ) there is a long list (23 issues!) of "accessibility" issues to be addressed prior to marking it stable, @bnjmnm identified most of those. See #3239423: Toolbar UI accessibility review: round 2 โ†’ in particular.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Clarifying that the original report is tightly coupled to Claro, which explains why the parent issue is #3163810: [META] Assess conformance with WCAG SC 2.4.7 "Focus Visible" โ†’ .

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mgifford Ottawa, Ontario
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    I hear the CKEditor 5 team is investigating this too as they encountered this problem while working on https://www.drupal.org/project/ckeditor5_premium_features โ†’ ๐Ÿ˜Š

    Really curious to get their feedback!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mherchel Gainesville, FL, US
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Closed ๐Ÿ› CKEditor 5 focus indicator is insufficient and is completely invisible in forced colors Closed: duplicate as a duplicate. Transferred tags & credit.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mgifford Ottawa, Ontario

    How is what we implemented different than what you can see in their demo https://ckeditor.com/ckeditor-5/demo/feature-rich/

    The contrast I see for the focus of the boarder is #3879EB / #FFF which is 4.1.2. That's good enough for SC 1.4.11 Non-Text Contrast (Level AA) if the visual presentation only needs a contrast ratio of 3:1 against adjacent color(s).

    I didn't see a corresponding problem in their issue queue https://github.com/ckeditor/ckeditor5/issues

    but the bigger issue is that i couldn't replicate this in their demo.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Related: ๐Ÿ“Œ Add outline to buttons with active state. Fixed just landed.

  • pere orga Catalonia

    This issue is about focus styles, but shouldn't be about styles, in general?

    What I first noticed is that the border is brighter in WYSIWYG fields:

    (also, it is not resizable, but that would likely be a separate issue)

    I agree this is not critical, nor very important. It would be great if consistency could be achieved, though. What I'm not sure is what would be the right solution, considering the toolbar also has a border.

    Idea A:

    Idea B:

    Idea C:

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rkoller Nรผrnberg, Germany

    Good catch @pere-orga! I strongly disagree, it is important since the ckeditor field isn't meeting WCAG 2.2. SC 1.4.11 that way (i've quickly checked) . A color contrast of at least 3:1 is required for the visual representation of user interface components (their states including focus indication and boundaries) and graphical objects. But i would consider the border color out of the scope for this issue and would suggest to open up a follow up issue, since changing the border color of the wysiwyg might be easier and faster done than adjusting the focus color for ckeditor?

  • pere orga Catalonia

    Happy to create a separate issue, but there may be many other CSS inconsistencies, especially if this hasn't been a goal.

    Regarding WCAG 2.2, shouldn't we aim to fix this upstream? Not only to avoid adding (and maintaining) more integration code that can break, but also to benefit the CKEditor project, and all the projects that use them.

    Related to the focus, I also noticed that when clicking on any blank space inside the toolbar, the green outline appears around the toolbar, partially behind the preview/editor pane:

    (not sure if this effect has been reported/identified before)

  • pere orga Catalonia

    I took a look and I don't think this is easy, it requires multiple style changes to CKEditor.

    So this is totally doable. At least for a specific theme. For Claro, we'd want

    --ck-color-focus-border: var(--color-focus);

    This changes the color of the border from blue to green, but it is not much better, because as far as I can see, Claro implements the green outline with box-shadow.

    Overriding the following selector gave me a better result:

    .ck.ck-editor__editable.ck-focused:not(.ck-editor__nested-editable) {
        box-shadow: var(--focus-box-shadow);
    }
    

    But still far from perfect: the CKEditor blue focus border is still there (and did not look good if removed, it should probably be converted to be var(--input-border-size) solid var(--input-border-color);, but even then, the green outline still would not match Claro's, mostly because the focused element only has 2 rounded corners instead of 4 (which is another non-focus style difference):

    Also, we would need to replicate the hover effect (border-color: var(--input--hover-border-color); box-shadow: inset 0 0 0 var(--input-border-size)...).

    And the issue I described in #32 would still happen.

  • Merge request !9811fix(claro): improve CKEditor focus โ†’ (Open) created by pere orga
  • pere orga Catalonia

    I found something simpler, looking at what Gin theme is doing:

    --- a/core/themes/claro/css/components/ckeditor5.pcss.css
    +++ b/core/themes/claro/css/components/ckeditor5.pcss.css
    @@ -1,3 +1,6 @@
     .ck {
       --ck-color-base-border: var(--input-border-color);
    +  --ck-focus-ring: 1px solid var(--color-focus);
    +  --ck-focus-outer-shadow: 0 0 0 2px var(--color-white), 0 0 0 5px var(--color-focus);
    +  --ck-inner-shadow: var(--ck-focus-outer-shadow);
     }
    

    This has the problems mentioned above, and a few pixels of the toolbar buttons are now below (behind) the green shadow, but I can't see how we could improve this if we apply current Claro's shadow:

  • pere orga Catalonia

    Setting it to Ready for review, as I've created an MR that could be acceptable.

    Replicating the hover effect could be a separate issue.

  • Pipeline finished with Success
    2 months ago
    Total: 4419s
    #306458
  • pere orga Catalonia

    Gin Admin theme also does this to mitigate #32:

    .ck-toolbar_grouping:focus,
      .ck-toolbar__items:focus {
        box-shadow: none;
      }
    }
    

    This completely hides the green line around the toolbar. Not doing it in case it can have issues for accessibility. I think it's probably OK though: I'm not sure the toolbar should be focusable at all (the toolbar can still be used by the keyboard when the editor is focused), but in that case, we may consider focusing the editor automatically when the empty space in the toolbar is clicked.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Scanning issue summary and appears to be missing a few sections.

    Proposed solution
    User interface change = before/after screenshots probably can be moved.

    My recommendation is even if a section doesn't apply to the issue just put N/A vs removing it.

  • pere orga Catalonia

    Updating issue description

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Still appears to be missing proposed solution section.

Production build 0.71.5 2024