Carbon: Focus outline on Code Snippet is unstyled

Created on 13 Apr 2019  ยท  15Comments  ยท  Source: carbon-design-system/carbon

When clicking in a code snippet, it appears that we have a un-styled focus indicator:

image

This is called (I believe) by tabindex="0" and role="textbox", which I believe is moreso meant for an area where you can freely edit text.

dev ๐Ÿค– visual ๐ŸŽจ a11y โ™ฟ bug ๐Ÿ›

Most helpful comment

Personally, I think the preliminary fix (no height adjustments) looks great and could be implemented immediately it seems. I like that it stays the same height in both macOS versions.

All 15 comments

cc @dakahn do you agree on the textbox stuff?

Yeah, exactly right. Wrong role. I can bundle these fixes in with some code snippet improvements that have been made recently to CCR. ๐Ÿ‘๐Ÿฝ

We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. Thanks for your contributions.

Looks like this was taken care of ๐Ÿ˜„

I was just about to open an issue about the focus style on code snippet and found this issue.
In the current version ([email protected]) I can replicate the screenshot from @joshblack

image

In the single-line codesnippet the focus style beyond the box, in the multi-line it's just unstyled:

image

Using Chrome v79 on macOs 10.14.6

Confirmed this is still present. @carbon-design-system/design , what should we do with this outline here?

Can we do something like this:
Artboard

With the way the component is set up, it doesn't seem like that is possible.

Screen Shot 2020-01-28 at 2 16 02 PM

Screen Shot 2020-01-28 at 2 16 32 PM

My recommendation would be to just remove the focus from the element since it is not interactive anyways. The focus will just go to the copy icon, then to show more.

ok yeah then lets just do that, have the focus on the copy icon and then the show more only^ .

Focus styles have been removed from multi-line snippet, @emyarod is going to look into a possible cross-browser / os solution to the single line snippet in a separate PR

just a proof of concept, still WIP but looking for feedback before I continue @laurenmrice @tw15egan

here's a screenshot dump but we can go over this in more detail later on. every category below has 3 images each showing Windows 10, macOS with hidden scrollbars, and macOS with visible scrollbars. the first set is the as-is, the second set is a CSS only fix, and the third set includes a proof of concept that includes JS.

as-is

default

as-is1
as-is1
as-is4

snippet focused

as-is2
as-is2
as-is5

copy button focused

as-is3
as-is3
as-is6

preliminary fix (no height adjustments)

default

p1
p1
p4

snippet focused

p2
p2
p5

copy button focused

p3
p3
p6

dynamically set height based on whether or not scrollbar is present

if the content is short and a scrollbar is not rendered, it will appear the same as the prelim fix screenshots above on macOS

default

z1
p1
z1

snippet focused

z2
p2
z2

copy button focused

z3
p3
z3

@emyarod thanks for taking the time to put these screencaps together ๐Ÿ™ Makes it very easy to illustrate the issue.

if the "preliminary fix (no height adjustments)" solution is fine then I can continue with that, but the proof of concept with a bit of tweaking might be worth implementing

Personally, I think the preliminary fix (no height adjustments) looks great and could be implemented immediately it seems. I like that it stays the same height in both macOS versions.

agreed, lets go for that ^

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AnthumChris picture AnthumChris  ยท  3Comments

ahoyahoy picture ahoyahoy  ยท  3Comments

snidersd picture snidersd  ยท  3Comments

carmacleod picture carmacleod  ยท  3Comments

jhpedemonte picture jhpedemonte  ยท  3Comments