-
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
feat(floating-menu): add focus wrap element to components #3652
feat(floating-menu): add focus wrap element to components #3652
Conversation
Deploy preview for the-carbon-components ready! Built with commit abf3402 https://deploy-preview-3652--the-carbon-components.netlify.com |
Deploy preview for carbon-elements ready! Built with commit abf3402 |
Deploy preview for carbon-components-react ready! Built with commit abf3402 https://deploy-preview-3652--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.
Thank you for coming up with a PR @elizabethsjudd!
{{ carbon-icon 'Close16' class=(add @root.prefix '--modal-close__icon') }} | ||
</button> | ||
</div> | ||
<div> |
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.
Why did you put additional <div>
rather than simply adding focus trap element to the last? Note that no user-visible focusable element should be put outside <div class="bx--modal-container">
.
packages/components/src/components/overflow-menu/overflow-menu.hbs
Outdated
Show resolved
Hide resolved
packages/components/src/components/overflow-menu/overflow-menu.hbs
Outdated
Show resolved
Hide resolved
<a href="#" class="{{@root.prefix}}--link">Learn More</a> | ||
<button class="{{@root.prefix}}--btn {{@root.prefix}}--btn--primary {{@root.prefix}}--btn--sm" | ||
type="button">Create</button> | ||
<div class="{{@root.prefix}}--tooltip-wrapper"> |
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.
Same question to overflow menu - Would you put the trap element next to <div class="bx--tooltip__footer">
?
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.
@asudoh the trap element needs to be outside of the content area of the tooltip not a sibling within it. Currently with the way that the trap element works, it can not be a direct sibling of the content area which in the case of tooltips content is any direct child of .bx--tooltip
Current structure of tooltip
<bx--tooltip>
<bx--tooltip__caret/>
<p>Tooltip content</p>
<bx--tooltip__footer/>
<!-- trap element is a sibling of content if placed here and doesn't work -->
<trap-element>
</bx--tooltip>
There are a couple different options:
1. Scope the content area
We could add a div within the tooltip around any of the content including the footer and update the event listener to watch the new div instead of the tooltip element
<bx--tooltip>
<bx--tooltip__caret/>
<div>
<p>Tooltip content</p>
<bx--tooltip__footer/>
</div>
<trap-element>
</bx--tooltip>
2. Add a unique selector to the trap element
We could give a unique selector to the trap element and watch for it to get focus and when it gets focus, immediate move it. If that's the case we can keep the original HTML structure.
<bx--tooltip>
<bx--tooltip__caret/>
<p>Tooltip content</p>
<bx--tooltip__footer/>
<span tabindex="0" class="bx--focus-trap"></span>
</bx--tooltip>
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.
My apologies, I seems to have missed this comment. I think 1. makes sense. BTW instead of wrapper node ref, let's move the root node up to the wrapper as above structure tells. If we need to refer to where the root node used to be, we can introduce options.selectorContent
. Thanks!
<a href="#" class="{{@root.prefix}}--link">Learn More</a> | ||
<button class="{{@root.prefix}}--btn {{@root.prefix}}--btn--primary {{@root.prefix}}--btn--sm" | ||
type="button">Create</button> | ||
<div class="{{@root.prefix}}--tooltip-wrapper"> |
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.
Some question as another instance of tooltip body.
<a href="#" class="{{@root.prefix}}--link">Learn More</a> | ||
<button class="{{@root.prefix}}--btn {{@root.prefix}}--btn--primary {{@root.prefix}}--btn--sm" | ||
type="button">Create</button> | ||
<div class="{{@root.prefix}}--tooltip-wrapper"> |
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.
Some question as another instance of tooltip body.
@asudoh here's the thought process behind my work
|
Thank you for explaining @elizabethsjudd. 1. makes sense to me and I'll withdraw my comments to overflow menu due to Wrt. 2., you are right that Angular, etc. requires root element. Modal already has two-level containers, though - One ( Wrt 3., I guess you meant where the content is put in with your "in component" wording. If so, my response to 2. would address it. |
…feature/floating-menu-focus-wrap
…feature/floating-menu-focus-wrap
@asudoh I made changes to each of the components so the span is contained within the component and added the |
@asudoh While I'm working on some of the more JS extensive issues for a11y, I feel like it might be easier for me to work in the evening/night so that we are on an overlapping schedule so that I can I can get feedback quicker. Right now the issue that I'm having is that I'm spending an hour or so a day working on tasks and then waiting for you to be able to respond. I recognize that with a 13 hour time difference this is expected but as I have more issues open I'm building more merge conflicts (which are never fun). I've already ran the idea of working one day a week with this different schedule with my team and they agree with this shift to help with communication and hopefully speed up the contribution process. Can we coordinate a day/times for me to do this schedule shift? |
The updated code looks basically good to me. Could you update tests? BTW thanks for ideas on collaboration, I pinged you offline for my ideas. |
…feature/floating-menu-focus-wrap
@asudoh tests have been updated and ready for re-review |
Cool thanks @elizabethsjudd! Would you want to cover your enhancements in the test as well? |
@asudoh the tests for the focus wrap feature seem to already be in there because the HTML has the old hidden input. Are you wanting me to test for the presence of the element or what? |
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.
Oh I didn't realize that, sorry @elizabethsjudd!
@carbon-design-system/developers This is still waiting on review. |
Will take a look at this! @elizabethsjudd can you update the PR title? It should follow our commit message conventions for our changelog. You can read more about this in our developer handbook. |
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 -- sorry for delays!
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.
Thanks so much for being patient our new(ish) system for assigning PRs to reviewers still has a few kinks to work out.
Closes #3603
Move the focusable element used for the focus wrap feature to be within the component so developers don't have to add a hidden element to get this feature. This impacts modal, tooltip, and overflow menu. Waiting on #3476 to be merged so I can test with the new functionality of tooltip.
Changelog
Changed
Testing / Reviewing
Test overflow menu, modal, and tooltip keyboard interactions