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
green focus outline for CKEditor 4 body field
CKeditor 5
blueish focus outline for CKEditor 5 body field

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.
focus triggered in the devtools for ckeditor5
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.

User interface changes

Before

ckeditor focus

After

ckeditor focus, after

Issue fork drupal-3272592

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rkoller created an issue. See original summary.

rkoller’s picture

Title: On node creation with a CKEditor5 text format there is a light blue instead of green outline » On node creation with a CKEditor5 text format there is a light blue instead of green outline on focus
rkoller’s picture

Component: Claro theme » ckeditor5.module
StatusFileSize
new31.72 KB
new254.91 KB

I've tested now in Seven in the latest 9.4.x-dev - again with Safari 13.1.2 and latest Firefox. Same results in Seven like the ones I describe for Claro in the IS.

When i tab into the body field the focus looks like that:
thin blue outline around the body field in Seven

When I manually trigger the focus in the devtools in Safari the focus looks like that.
regular focus outline around the body field in Seven

As it turns out it isn't an Claro exclusive issue I move the component from Claro to CKEditor5 since the issue doesn't take place in CKEditor4. I leave the parent issue as is since it is still relevant for the Claro focus meta issue.

rkoller’s picture

StatusFileSize
new19.7 KB

quick update. i've noticed today that the toolbar icons have the blueish outline as well instead of the regular green one.

ckeditor 5 toolbar with one icon with a blueish focus outline instead of the regular green one

wim leers’s picture

I bet these are CKEditor 5's styles.

I think you're effectively asking that Claro and Seven provide overrides of CKEditor 5's default styling to use the same focus styling as those admin themes?

bnjmnm’s picture

I bet these are CKEditor 5's styles.

I just confirmed that to be the case.

I very much see the appeal in making the focus rings consistent, but overriding CKEditor 5's default styling presents some risks, especially since CKEditor 5 releases new major versions at a Javascripty pace. If they change their focus styling approach, there could be conflicts such as box shadows and outlines clashing with each other, or focus ring inconsistency within the editor. These are kind of difficult to test, so the issue could be introduced without us realizing it. At least now the focus ring appearance change is predictable (inside CK it looks one way, outside it looks another).

The contrast/visibility concerns are worth addressing, but I wonder if this is best done upstream in CKEditor 5 itself. This still means inconsistent focus rings within a theme, but it would be predictably inconsistent, and not jarring. Uniform styling is ideal, but it's also understood that there may be differences with 3rd party widgets.

Wim Leers credited Reinmar.

Wim Leers credited oleq.

wim leers’s picture

Title: On node creation with a CKEditor5 text format there is a light blue instead of green outline on focus » CKEditor 5 has its own focus styles, should use the admin theme's
Category: Bug report » Task
Issue tags: +CSS

Per #6, re-classifying from bug to task.

I asked the CKEditor 5 team for advice. @Reinmar escalated this question to @oleq.

I asked:

https://www.drupal.org/project/drupal/issues/3272592#comment-14472622 → is it likely that CKE5 will at some point change its focus styles? We’re contemplating overriding them to make them consistent with the theme, but we don’t want to risk breakage with every CKE5 release.

@oleq's response:

No, we don’t plan anything like that.
But if you want to override our focus styles, all you have to do is override --ck-focus-ring and --ck-focus-outer-shadow CSS properties.
(Unless you override them, find out that something is inconsistent/broken/just wrong, then yes, we’ll have to address this sooner or later 😛

So … I think that means we could consider overriding this on the Drupal side. I defer to @bnjmnm and @lauriii on this.

wim leers’s picture

Issue tags: +ddd2022
wim leers’s picture

Issue tags: -ddd2022

Well, actually, no, this was found by @rkoller at home, not at DDD Ghent. 😅 I just responded while being at DDD. So untagging. Sorry for the noise.

lauriii’s picture

I agree that it could be nice to render the focus style consistently in Claro. However, I don't think this is critical because CKEditor 5 has its own design language, and we are not planning to customize all of that to match the Drupal design system.

There are some challenges with the Claro focus styles because in CKEditor 5, the focus is around the preview container, not the whole editor. We probably don't want the outline to render over the toolbar since the toolbar will need to remain usable while the preview container is focused. We also need to decide what to do about selected widgets, should those styles follow Claro too?

Either way, it would be good to play around with this a bit, and see how it would look like to make a final decision on what makes sense.

wim leers’s picture

Thanks for sharing your rationale in such detail! 🙏

Per #6 and #12, this is clearly not a stable blocker then.

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.

wim leers’s picture

https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/ui... actually seems to make this trivial to implement:

    --ck-color-focus-border: #26a769;

Also see packages/ckeditor5-theme-lark/theme/ckeditor5-ui/globals/_focus.css, which contains:

:root {
	/**
	 * The geometry of the of focused element's outer shadow.
	 */
	--ck-focus-outer-shadow-geometry: 0 0 0 3px;

	/**
	 * A visual style of focused element's outer shadow.
	 */
	--ck-focus-outer-shadow: var(--ck-focus-outer-shadow-geometry) var(--ck-color-focus-outer-shadow);

	/**
	 * A visual style of focused element's outer shadow (when disabled).
	 */
	--ck-focus-disabled-outer-shadow: var(--ck-focus-outer-shadow-geometry) var(--ck-color-focus-disabled-shadow);

	/**
	 * A visual style of focused element's outer shadow (when has errors).
	 */
	--ck-focus-error-outer-shadow: var(--ck-focus-outer-shadow-geometry) var(--ck-color-focus-error-shadow);

	/**
	 * A visual style of focused element's border or outline.
	 */
	--ck-focus-ring: 1px solid var(--ck-color-focus-border);
}

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

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

AFAICT.

And … if Drupal core settles on consistently named CSS variables, that single line should be able to work for any admin theme? 🤓

wim leers’s picture

@rkoller reported this problem again at #3308911: The CKEditor 5 form-element is missing an outline color change on hover. Marked it as a duplicate.

See the video he posted there: https://www.drupal.org/files/issues/2022-09-09/outline.mp4.

rkoller’s picture

oh that is the same root cause like the focus issue?! i was unaware of that. i just noticed that there was also no effect on hover but since hover and focus have different styling and different triggers not thought it might be the same root cause.

wim leers’s picture

Yes, same root cause AFAICT, because #3308911: The CKEditor 5 form-element is missing an outline color change on hover is also referring to Claro-only styles. 😅

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.

mgifford’s picture

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?

wim leers’s picture

#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.

wim leers’s picture

Title: CKEditor 5 has its own focus styles, should use the admin theme's » CKEditor 5 has its own focus styles, should use the admin theme's (e.g. Claro's)

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".

mgifford’s picture

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

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!

wim leers’s picture

mgifford’s picture

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.

wim leers’s picture

pere orga’s picture

StatusFileSize
new37.01 KB
new35.53 KB
new35.98 KB
new8.63 KB

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:

ckeditor vs plain

(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:

ckeditor vs plain

Idea B:

ckeditor vs plain

Idea C:

ckeditor vs plain

rkoller’s picture

Issue tags: +wcag1411, +wcag2413

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? And I would vote for variant A - the only one where the toolbar buttons as well as the wysiwyg field have a large enough color contrast and therefore are distinguishable.

pere orga’s picture

StatusFileSize
new65.77 KB

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:

outline weird behaviour

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

pere orga’s picture

pere orga’s picture

StatusFileSize
new75.19 KB

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-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):

claro/ckeditor outline hack

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.

pere orga’s picture

StatusFileSize
new42.18 KB

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:

calro shadow

pere orga’s picture

Status: Active » Needs review

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.

pere orga’s picture

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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

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’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new39.54 KB

Updating issue description

smustgrave’s picture

Still appears to be missing proposed solution section.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Per #41

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.