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(search): switch search role from datatable to search, add labeledby #5330

Merged
merged 8 commits into from
Feb 14, 2020
Merged

fix(search): switch search role from datatable to search, add labeledby #5330

merged 8 commits into from
Feb 14, 2020

Conversation

abbeyhrt
Copy link
Contributor

Closes #5289
Closes: #4665

This PR removes role="search" from TableToolbarSearch and adds it to the outer div of the search component and adds an id to the label so that the search is labeled by labelText and can be made unique to each Search bar if there are multiple on a page, for example if someone has a search component for the page and one inside a data table.

Changelog

New

  • id for Search label
  • search role on Search component

Changed

  • updated snapshots

Removed

  • search role from TableToolbarSearch

Testing / Reviewing

Inspect the Search component in or outside of a data table and check that aria-labelledby with a unique id is being applied to the div with role="search" .

@abbeyhrt abbeyhrt requested a review from a team as a code owner February 12, 2020 18:14
@ghost ghost requested review from asudoh and joshblack February 12, 2020 18:14
@abbeyhrt abbeyhrt requested a review from dakahn February 12, 2020 18:14
@netlify
Copy link

netlify bot commented Feb 12, 2020

Deploy preview for carbon-elements ready!

Built with commit 241dcc9

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

@netlify
Copy link

netlify bot commented Feb 12, 2020

Deploy preview for carbon-components-react ready!

Built with commit 241dcc9

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

@@ -162,9 +162,12 @@ export default class Search extends Component {
const CloseIconX = size === 'xl' ? Close20 : Close16;

return (
<div className={searchClasses}>
<div
role="search"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this always be on the <Search> component? I'm just not sure what the impact is 🤔

It seems like role="search" is treated as a landmark and if folks are using this frequently it might clutter the list of regions on the page if we default here versus over in TableToolbarSearch we should have ideally one version of itself on thepage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I read, it seems like even if there are multiple searches on a page, each one still should be a landmark with a unique label of what it is for (data table, the whole site, etc). Since we didn't make the input type "search", the Search component isn't a landmark right now and probably should be without users needing to add it.

<Search16 className={`${prefix}--search-magnifier`} />
<label htmlFor={id} className={`${prefix}--label`}>
<label id={id + '-search'} htmlFor={id} className={`${prefix}--label`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it'd help out to create a variable like const searchId = ${id}-search; and use it in both spots? Just so updates to one location are mirrored in the other location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I'll add it!

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - Thanks @abbeyhrt!

@abbeyhrt abbeyhrt merged commit 7e4c0e5 into carbon-design-system:master Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants