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

feat(Tag): support click handler for filter tag close icon #5470

Merged

Conversation

emyarod
Copy link
Member

@emyarod emyarod commented Feb 27, 2020

Closes #5419

This PR adds support for a click handler on the filter tag close icon

Changelog

New

  • onClose prop support for filter tag

Testing / Reviewing

Ensure that the proper events are fired depending on the click target in filter tags

@emyarod emyarod requested a review from a team as a code owner February 27, 2020 21:28
@ghost ghost requested review from abbeyhrt and dakahn February 27, 2020 21:28
@emyarod
Copy link
Member Author

emyarod commented Feb 27, 2020

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

@emyarod emyarod requested a review from aagonzales February 27, 2020 21:31
@netlify
Copy link

netlify bot commented Feb 27, 2020

Deploy preview for carbon-components-react ready!

Built with commit 8390593

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

@netlify
Copy link

netlify bot commented Feb 27, 2020

Deploy preview for carbon-elements ready!

Built with commit 8390593

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

Copy link
Member

@aagonzales aagonzales left a comment

Choose a reason for hiding this comment

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

It looks like clicking on tag area is still activating the x.
Feb-27-2020 16-31-47

@aagonzales
Copy link
Member

aagonzales commented Feb 27, 2020

And I don't think the x should add a tab stop, but it should be trigger on keyboard nav by clicking esc and/or allow arrow + enter. I'm not sure what would be the best practice.

@emyarod
Copy link
Member Author

emyarod commented Feb 27, 2020

it only appears that the x is focused, but it does not fire the same event:

actions

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

Copy link
Member

@aagonzales aagonzales left a comment

Choose a reason for hiding this comment

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

  1. Filter tag color knob isn't working
    Feb-28-2020 14-19-20

  2. Different focus states for tag area and close x
    image

  3. 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?

@emyarod
Copy link
Member Author

emyarod commented Mar 2, 2020

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

@emyarod emyarod force-pushed the 5419-filter-tag-close-handler branch from d4d39e6 to 8f3b32f Compare March 2, 2020 19:57
@dakahn
Copy link
Contributor

dakahn commented Mar 2, 2020

Agreed @emyarod any mouse functionality should have a keyboard only alternative as well

@abbeyhrt
Copy link
Contributor

abbeyhrt commented Mar 3, 2020

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.

@aagonzales
Copy link
Member

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.

This is the behavior that needs to be corrected:
Mar-03-2020 11-48-08

@emyarod
Copy link
Member Author

emyarod commented Mar 3, 2020

ok so in that case we are just moving the only clickable area from the tag body to the close icon?

@aagonzales
Copy link
Member

Yes

image

@emyarod
Copy link
Member Author

emyarod commented Mar 3, 2020

ok since the tag body is currently a button element, by default it will have a tab stop. in that case I will change the base element of the tag body to something else. this may be a breaking change if users have been attaching click handlers to the tag body so we will have to announce this change

@emyarod emyarod force-pushed the 5419-filter-tag-close-handler branch from 8f3b32f to 6621f3d Compare March 3, 2020 18:16
@emyarod emyarod requested a review from aagonzales March 3, 2020 18:17
@emyarod emyarod force-pushed the 5419-filter-tag-close-handler branch from 6621f3d to 4f146b3 Compare March 3, 2020 18:17
@asudoh
Copy link
Contributor

asudoh commented Mar 3, 2020

@emyarod Is this ready for re-review...? Thanks!

@emyarod
Copy link
Member Author

emyarod commented Mar 4, 2020

@asudoh yes this is ready for re-review

Copy link
Member

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


&:hover {
background-color: $inverse-hover-ui;
}
}

.#{$prefix}--tag--filter:focus > svg {
.#{$prefix}--tag__close-icon svg {
fill: $inverse-01;
Copy link
Contributor

@abbeyhrt abbeyhrt Mar 4, 2020

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

Copy link
Member Author

@emyarod emyarod Mar 4, 2020

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?

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.

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}>
Copy link
Contributor

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?

Copy link
Member Author

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

@emyarod emyarod force-pushed the 5419-filter-tag-close-handler branch from 4f146b3 to 7422043 Compare March 5, 2020 16:18
@asudoh
Copy link
Contributor

asudoh commented Mar 5, 2020

@joshblack Any further comments...? Thanks!

Copy link
Contributor

@dakahn dakahn left a 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
2020-03-05 17_29_53-Storybook

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
2020-03-05 17_59_38-Storybook

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 🎉
2020-03-05 18_00_43-Storybook

@emyarod emyarod force-pushed the 5419-filter-tag-close-handler branch from 7422043 to a368d5f Compare March 6, 2020 14:51
@emyarod emyarod requested a review from dakahn March 6, 2020 15:19
@emyarod emyarod force-pushed the 5419-filter-tag-close-handler branch from a368d5f to a3eb65d Compare March 10, 2020 15:15
Copy link
Contributor

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

@asudoh asudoh merged commit 57f48c0 into carbon-design-system:master Mar 10, 2020
@emyarod emyarod deleted the 5419-filter-tag-close-handler branch March 11, 2020 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX bug: Filterable tag should have separate click behavior for tag body and "x"
7 participants