-
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(Tag): support click handler for filter tag close icon #5470
feat(Tag): support click handler for filter tag close icon #5470
Conversation
now that there are 2 distinct click targets for filter tags, should there be an extra tab stop? if so, should there be a visual difference between the tag body on focus and the tag close icon on focus? cc @aagonzales |
Deploy preview for carbon-components-react ready! Built with commit 8390593 https://deploy-preview-5470--carbon-components-react.netlify.com |
Deploy preview for carbon-elements ready! Built with commit 8390593 |
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.
And I don't think the x should add a tab stop, but it should be trigger on keyboard nav by clicking |
it only appears that the x is focused, but it does not fire the same event: so I'm wondering if there should be a visual difference between tag body focus and close icon focus. but since you said there shouldn't be an added tab stop the current focus behavior of outlining the close icon may be confusing |
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.
-
I would not think the x would be in the tab order, I think it would get excessive to read tab label then read the close function for every tab if there are many. I will defer to the accessibility team on this however. @dakahn any thoughts?
FYI for filter tag color knob #3318 I think there would need to be an extra tab stop if we will differentiate tag body actions from close icon actions, otherwise the full component functionality wouldn't be available to keyboard only users (unless pressing Esc to close while the tag body is focused is sufficient), will await updated guidance |
d4d39e6
to
8f3b32f
Compare
Agreed @emyarod any mouse functionality should have a keyboard only alternative as well |
Is there any reason that the tag area needs focus? If it isn't going to dismiss the tag then the only thing that needs to receive focus accessibility-wise would be the close icon, I believe. |
No, I don't think the content needs a focus I just don't want the focus for the x to appear when the user clicks on the content area. The user must click on the x to close the icon and it seems confusing that the focus would appear when not clicking directly on the x. |
ok so in that case we are just moving the only clickable area from the tag body to the close icon? |
ok since the tag body is currently a |
8f3b32f
to
6621f3d
Compare
6621f3d
to
4f146b3
Compare
@emyarod Is this ready for re-review...? Thanks! |
@asudoh yes this is ready for re-review |
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 now!
|
||
&:hover { | ||
background-color: $inverse-hover-ui; | ||
} | ||
} | ||
|
||
.#{$prefix}--tag--filter:focus > svg { | ||
.#{$prefix}--tag__close-icon svg { | ||
fill: $inverse-01; |
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.
For my own edification, why did you pull this out? I see it done a lot throughout our styles and I just wanted to learn why, thanks! 😄
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.
are you referring to the class (.bx--tag--filter
to .bx--tag__close-icon
)? or the >
selector?
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! 🎉
@@ -53,8 +58,10 @@ const Tag = ({ | |||
<span className={`${prefix}--tag__label`}> | |||
{children !== null && children !== undefined ? children : TYPES[type]} | |||
</span> | |||
<Close16 /> | |||
</button> | |||
<button className={`${prefix}--tag__close-icon`} onClick={handleClose}> |
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.
With the button shifting over will we also need to move the aria-label
over?
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.
not sure but the aria label was removed from the close button to the tag body in #4863
4f146b3
to
7422043
Compare
@joshblack Any further comments...? Thanks! |
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.
Tested with JAWS 2020 on Windows 10. The button is read as "clear filter this is not a tag unlabeled 1 button"
Looks like the button under the hood has no label
Worth noting as well is NVDA reads this as "main landmark clickable button" -- so not even picking up the tag text at all there.
And we've also got the expected subsequent DAP error
Adding an aria-labelledby
attribute referencing an id
on that wrapper div with the aria-label
seems to fix both JAWS and NVDA and clear the DAP error though 🎉
7422043
to
a368d5f
Compare
a368d5f
to
a3eb65d
Compare
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.
Sounds good and reads well 👍 DAP errors cleared
Closes #5419
This PR adds support for a click handler on the filter tag close icon
Changelog
New
onClose
prop support for filter tagTesting / Reviewing
Ensure that the proper events are fired depending on the click target in filter tags