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(listbox): use filter tag #5952

Closed
wants to merge 17 commits into from

Conversation

janhassel
Copy link
Member

Use <Tag /> component in ListBoxes instead of custom styles to ensure styling is up-to-date.

Changelog

New

  • Included Tag in ListBoxSelection

Removed

  • Custom styling for "tag clone" in ListBoxes
  • handleOnKeyDown in ListBoxSelection (see question below)

Testing / Reviewing

Automated tests should make sure functionality isn't affected. Visually, new implementation and old implementation should look the same.

The tests are currently failing since I removed the current keydown logic. Tbh, checking out the current implementation I am a bit confused about the keyboard navigation and therefore wanted to see if that might need to be updated before re-creating it.

@janhassel janhassel requested a review from a team as a code owner April 28, 2020 07:09
@ghost ghost requested review from dakahn and emyarod April 28, 2020 07:10
@janhassel
Copy link
Member Author

Elaborating on the keyboard question, I'm wondering if...

  • the listbox should open/close on Enter as well (like a dropdown)
  • the listbox should close on blur (like a dropdown)
  • the tabstop on the list of options can be omitted
    • image

@netlify
Copy link

netlify bot commented Apr 28, 2020

Deploy preview for carbon-elements ready!

Built with commit d62061a

https://deploy-preview-5952--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Apr 28, 2020

Deploy preview for carbon-components-react ready!

Built without sensitive environment variables with commit d62061a

https://deploy-preview-5952--carbon-components-react.netlify.app

@asudoh
Copy link
Contributor

asudoh commented Apr 28, 2020

Thanks @janhassel for your contribution. Do you want to resolve style dependency as well? (Note that usage of our entrypoint Sass code is not recommended for apps for performance sake)

the listbox should open/close on Enter as well (like a dropdown)
the listbox should close on blur (like a dropdown)

Agreed personally, though I'd like separate issues/PRs for those

the tabstop on the list of options can be omitted

I imagine so, but I don't see it's keyboard-focusable (only programmatic-focusable)

@janhassel
Copy link
Member Author

@asudoh Good point, I improted the tag styles into list-box.scss. Also restored the onKeyDown handler to be on par with the current interaction.

I'll update the snapshots once #5951 is merged as there are some overlaps.

@@ -49,17 +48,17 @@ const ListBoxSelection = ({
};
const description = selectionCount ? t('clear.all') : t('clear.selection');
return (
<div
role="button"
<Tag
Copy link
Member

Choose a reason for hiding this comment

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

I think we can add the disabled prop here so we can get the correct styles when the multiselect is disabled

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking that too and compared it to the current implementation where the tag styling is not changed on disable.

Personally I would also prefer to have the tag disabled since otherwise it really stands out. Do you if there was a reason behind the current implementation, like keeping it well readable for accessibility maybe?

Copy link
Member

Choose a reason for hiding this comment

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

it looks like there is a slight color change on the disabled tag svg in the current multiselect, but I'm not sure if it should look like the standalone disabled tag styles cc @laurenmrice

Copy link
Member Author

Choose a reason for hiding this comment

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

Just as a reference: this is how it would look when the tag enters disabled state as well:
image

Copy link
Member

@laurenmrice laurenmrice Apr 30, 2020

Choose a reason for hiding this comment

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

Let me make a spec for this 👍🏻, will get back to you shortly

Copy link
Member

Choose a reason for hiding this comment

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

This is what we can do for a selected-disabled state.

tags

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the quick specs, @laurenmrice 👍
I updated the tag color for the disabled state accordingly, you can check it out in the deploy preview: https://5eaae7cd3ab6150007c0340b--carbon-components-react.netlify.app/?path=/story/multiselect--default

@dakahn
Copy link
Contributor

dakahn commented Apr 29, 2020

Elaborating on the keyboard question, I'm wondering if...

  • the listbox should open/close on Enter as well (like a dropdown)
  • the listbox should close on blur (like a dropdown)
  • the tabstop on the list of options can be omitted

With a combobox specifically:

  • neither Enter or Spacebar should open or close the listbox dropdown. Only either A) entering a text value into the field or in some cases B) hitting ArrowDown should open the listbox. This keyboard interaction is described in detail at this link.

  • the listbox should close on blur

  • Although they're not tabstops, focus should move to the option being highlighted in the listbox dialog as described here under the Keyboard Support section

The current Carbon Filterable Multiselect component is far more complex and includes many unexpected features and interactions (which can/have proven problematic for our screen reader and keyboard users), but when triaging or remediating accessibility bugs moving forward we'll reference the WAI-ARIA Authoring Practices Guidelines for how to proceed.

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.

  • The button is keyboard accessible 🥂. The only point of contention I have is that it's read by JAWS 2020 and NVDA as "Clear selection button" without any information about the selected items the user would be clearing by activating it.

  • There also seems to be some styling that's off in Chrome latest on Windows 10
    image

@janhassel
Copy link
Member Author

@dakahn Thanks for catching that, I fixed the styling, should be correctly aligned now.

Regarding the first point: I removed the explicit aria-label and VoiceOver now reads "Clear all 2, button". Sadly I currently don't have access to our windows machine to test with JAWS, could you see if it works there as well?

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.

Hey Jan, just one thing: When disabled, the tag should also be getting the disabled cursor.

@janhassel
Copy link
Member Author

@laurenmrice
Copy link
Member

It still seems to be showing up on the x

May-01-2020 10-15-45

@laurenmrice
Copy link
Member

laurenmrice commented May 1, 2020

Also I am not sure if this is related to this pr (its not happening in the live react version) but when filtering a multiselect, the closex is using a tag.
Screen Shot 2020-05-01 at 10 18 11 AM

@janhassel
Copy link
Member Author

@laurenmrice The issue with the X button on the filter will be addressed in #5996
Thanks for noticing the X button issue in the filterable multiselect, this is indeed caused by the changes in this PR, I'll make sure to fix it!

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.

This looks good to me. thank you Jan! 👍🏻

@janhassel
Copy link
Member Author

@dakahn I'm wondering what the best strategy would be for this issue: validateDOMNesting(...): <button> cannot appear as a descendant of <button>

The Tag component uses a <button> for its remove button. The .bx--list-box__field element is also a <button> and contains a tag component. Therefore the tests report invalid DOM nesting. On master, the tag appearing inside the MultiSelect is a <div> with role="button" which makes it technically valid.

I see four main ways to go from here:

  1. Discard this PR, leave the custom tag
  • This might result in inconsistencies (both visual and interaction) between the actual Tag component and the tag displayed in MultiSelect component.
  1. Modify the Tag component
  • Instead of using a <button> for the remove button, we could use a <div> with role="button", basically making the Tag component behave as the custom tag behaved before.
  1. Modify the ListBox field element
  • Same as with the tag: use a div instead of a button element. Might bring problems with downshift (not tested/confirmed)
  1. Unnest tag from field
  • One obvious solution would be to unnest the two elements, this would bring in complexity to account for the right styling when a tag is displayed vs. when there is no tag.

I'm unsure which of these options would be the best. Maybe I'm also missing an obvious one here?
What do you think?

@joshblack
Copy link
Contributor

Hey @janhassel! Sorry for the delay in response, this is definitely a problem with the main widget with the button in a button. bump @dakahn again if you have any thoughts on the above questions and what we would need to do.

@dakahn
Copy link
Contributor

dakahn commented Jun 22, 2020

First option seems like the safest path of least resistance to me. Buttons with descendant buttons make multiple appearances in our code base sadly. We can come up with ways to address any hypothetical future visual inconsistency. Refactoring to a div isn't out of the question, but that will require careful work to ensure we don't break/degrade the experience for our screen reader users across the types of readers, browsers, and OSs' we build for.

@dakahn
Copy link
Contributor

dakahn commented Jun 22, 2020

related #5880

@janhassel
Copy link
Member Author

Ok, that sounds reasonable! Feel free to close the PR in this case.

If this is an overall accessibility issue with other components as well I'd be interested in how this will be addressed. Is it something you guys have on the roadmap for v11 or later?

@dakahn
Copy link
Contributor

dakahn commented Jun 29, 2020

Honestly, we need to rethink fundamental design decisions around element layout in a number of components with nested interactables. Buttons in buttons is a very pressing issue that we should get to way before v11 if I have my way.

@dakahn dakahn closed this Jun 29, 2020
@janhassel janhassel deleted the listbox-tag branch July 21, 2020 15:29
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.

6 participants