Skip to content
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

Merged
merged 5 commits into from
Jan 29, 2020

Conversation

tw15egan
Copy link
Member

@tw15egan tw15egan commented Jan 28, 2020

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

  • Reset focus styles on the code snippet container when multiline

Removed

  • tabindex and role on multiline code snippet

Testing / Reviewing

Tab through / click on CodeSnippet and ensure no focus is given to the container. The focus should move to the copy button.

@tw15egan tw15egan requested a review from a team as a code owner January 28, 2020 22:39
@ghost ghost requested review from abbeyhrt and dakahn January 28, 2020 22:39
@netlify
Copy link

netlify bot commented Jan 28, 2020

Deploy preview for the-carbon-components ready!

Built with commit 1ffae8c

https://deploy-preview-5202--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Jan 28, 2020

Deploy preview for carbon-elements ready!

Built with commit 870e3a7

https://deploy-preview-5202--carbon-elements.netlify.com

@asudoh asudoh requested review from a team and laurenmrice and removed request for a team January 28, 2020 23:09
@netlify
Copy link

netlify bot commented Jan 28, 2020

Deploy preview for carbon-components-react failed.

Built with commit 870e3a7

https://app.netlify.com/sites/carbon-components-react/deploys/5e30b827b22c38000821c2ae

@netlify
Copy link

netlify bot commented Jan 28, 2020

Deploy preview for carbon-elements ready!

Built with commit 1ffae8c

https://deploy-preview-5202--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Jan 28, 2020

Deploy preview for carbon-components-react ready!

Built with commit 1ffae8c

https://deploy-preview-5202--carbon-components-react.netlify.com

Copy link
Member

@emyarod emyarod left a 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

Comment on lines 93 to 97
.#{$prefix}--snippet--single .#{$prefix}--snippet-container,
.#{$prefix}--snippet--multi .#{$prefix}--snippet-container {
@include focus-outline('reset');
}

Copy link
Member

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?

Copy link
Member

@laurenmrice laurenmrice left a 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

@abbeyhrt
Copy link
Contributor

abbeyhrt commented Jan 29, 2020

@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!

@tw15egan
Copy link
Member Author

@abbeyhrt hmm, makes sense... Not sure what we want to do in regards to that focused state then.

@tw15egan
Copy link
Member Author

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

@laurenmrice
Copy link
Member

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.

@abbeyhrt
Copy link
Contributor

@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?
Screen Shot 2020-01-29 at 11 59 44 AM

@tw15egan
Copy link
Member Author

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
Screen Shot 2020-01-29 at 10 05 09 AM

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.

@abbeyhrt
Copy link
Contributor

@tw15egan that's totally fair, that list of issues hurts my head haha. I'm good with closing this and keeping the original focus! 👍

@tw15egan tw15egan closed this Jan 29, 2020
@laurenmrice
Copy link
Member

laurenmrice commented Jan 29, 2020

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.

@tw15egan
Copy link
Member Author

Just removing focus? Yeah we can add that into that variant

@tw15egan tw15egan reopened this Jan 29, 2020
@tw15egan
Copy link
Member Author

@laurenmrice just pushed some updates, let me know if this works 👍

Copy link
Member

@laurenmrice laurenmrice left a 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 🙌🏻

Copy link
Contributor

@abbeyhrt abbeyhrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@tw15egan
Copy link
Member Author

@emyarod updated, if you want to take a 2nd look

Copy link
Member

@emyarod emyarod left a 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

@tw15egan
Copy link
Member Author

tw15egan commented Jan 29, 2020

Go for it! I'll detach the issue from this PR and just leave a ref.

@tw15egan tw15egan merged commit 625a98b into carbon-design-system:master Jan 29, 2020
@tw15egan tw15egan deleted the remove-snippet-focus branch January 29, 2020 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants