-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(code-snippet): remove focus from snippet container #5202
fix(code-snippet): remove focus from snippet container #5202
Conversation
Deploy preview for the-carbon-components ready! Built with commit 1ffae8c https://deploy-preview-5202--the-carbon-components.netlify.com |
Deploy preview for carbon-elements ready! Built with commit 870e3a7 |
Deploy preview for carbon-components-react failed. Built with commit 870e3a7 https://app.netlify.com/sites/carbon-components-react/deploys/5e30b827b22c38000821c2ae |
Deploy preview for carbon-elements ready! Built with commit 1ffae8c |
Deploy preview for carbon-components-react ready! Built with commit 1ffae8c https://deploy-preview-5202--carbon-components-react.netlify.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove the tabindex
attributes from the vanilla docs so it will show up correctly there too
.#{$prefix}--snippet--single .#{$prefix}--snippet-container, | ||
.#{$prefix}--snippet--multi .#{$prefix}--snippet-container { | ||
@include focus-outline('reset'); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't needed if we are removing the tabIndex={0}
from the element right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
The show more button needs to get a 2px focus border instead of 3px.
-
Also I noticed show more ghost button text is mono and needs to be sans
body-short-01
@tw15egan unfortunately the single line code snippets need to receive focus since they are scrollable. Without it, a keyboard user doesn't have visual access to the whole snippet. This change definitely works for the multi-line snippets though! |
@abbeyhrt hmm, makes sense... Not sure what we want to do in regards to that focused state then. |
Looking at a few other design systems, and none of their code components receive focus 🤔. The focus goes straight to the copy button. We might just have to live with the browser focus if we want to keep that functionality |
is there no way around creating a focus that has to go outside to accommodate the horizontal scrollbar? i guess if anything if its only for single line in some browsers we could leave it for now. |
@tw15egan I do think the browser focus being misshapen looks less weird than our focus styles misshapen. It seems like this 16px padding-bottom is making the focus the way it is and it seems to be there to vertically center the text, is there a way to vertically center the text without that padding? |
This is just one of those components that tends to look different in various browsers/os due to the way the system handles scrolling, i.e I'm hesitant to change the padding / internal structure, which could cause more issues (List of issues) with misalignment in browsers, just to get a perfect focus state. It seems like more work than the perceived benefit. I'm good with closing this and the original focus issue with a won't fix tag. |
@tw15egan that's totally fair, that list of issues hurts my head haha. I'm good with closing this and keeping the original focus! 👍 |
Can we still keep the changes you did for the multiline code snippet since we don't need it on that variant? I am fine with keeping the single line as it was if there isn't an easy fix for that. |
Just removing focus? Yeah we can add that into that variant |
9cbb647
to
2f6ce92
Compare
8e0b9f3
to
b71eb23
Compare
@laurenmrice just pushed some updates, let me know if this works 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes looks great ! thank you 🙌🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
@emyarod updated, if you want to take a 2nd look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, I kinda want to keep the ticket open to look a bit more into the single line snippet scroll stuff since I think there's a solution for it
Go for it! I'll detach the issue from this PR and just leave a ref. |
Refs #2304
Removes focus outline from the main text part of the Code Snippet (MultiLine only). The focus will now go directly to the copy button, then show more.
Changelog
New
Removed
tabindex
androle
on multiline code snippetTesting / Reviewing
Tab through / click on
CodeSnippet
and ensure no focus is given to the container. The focus should move to the copy button.