Skip to content

Commit

Permalink
fix(search): switch search role from datatable to search, add labeled…
Browse files Browse the repository at this point in the history
…by (#5330)

* fix(search): switch search role from datatable to search, add labeledby
  • Loading branch information
abbeyhrt authored Feb 14, 2020
1 parent b49d587 commit 7e4c0e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ const TableToolbarSearch = ({
return (
<div
tabIndex={expandedState ? '-1' : tabIndex}
role="search"
ref={searchRef}
onClick={event => onClick(event)}
onFocus={event => handleExpand(event, true)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,6 @@ exports[`DataTable should render 1`] = `
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
role="search"
tabIndex="0"
>
<Search
Expand All @@ -2261,7 +2260,9 @@ exports[`DataTable should render 1`] = `
value=""
>
<div
aria-labelledby="custom-id-search"
className="bx--search bx--search--sm"
role="search"
>
<ForwardRef(Search16)
className="bx--search-magnifier"
Expand Down Expand Up @@ -2298,6 +2299,7 @@ exports[`DataTable should render 1`] = `
<label
className="bx--label"
htmlFor="custom-id"
id="custom-id-search"
>
Filter table
</label>
Expand Down Expand Up @@ -3242,7 +3244,6 @@ exports[`DataTable sticky header should render 1`] = `
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
role="search"
tabIndex="0"
>
<Search
Expand All @@ -3258,7 +3259,9 @@ exports[`DataTable sticky header should render 1`] = `
value=""
>
<div
aria-labelledby="custom-id-search"
className="bx--search bx--search--sm"
role="search"
>
<ForwardRef(Search16)
className="bx--search-magnifier"
Expand Down Expand Up @@ -3295,6 +3298,7 @@ exports[`DataTable sticky header should render 1`] = `
<label
className="bx--label"
htmlFor="custom-id"
id="custom-id-search"
>
Filter table
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ exports[`DataTable.TableToolbarSearch should render 1`] = `
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
role="search"
tabIndex="0"
>
<Search
Expand All @@ -31,7 +30,9 @@ exports[`DataTable.TableToolbarSearch should render 1`] = `
value=""
>
<div
aria-labelledby="custom-id-search"
className="bx--search bx--search--sm custom-class"
role="search"
>
<ForwardRef(Search16)
className="bx--search-magnifier"
Expand Down Expand Up @@ -68,6 +69,7 @@ exports[`DataTable.TableToolbarSearch should render 1`] = `
<label
className="bx--label"
htmlFor="custom-id"
id="custom-id-search"
>
Filter table
</label>
Expand Down
6 changes: 4 additions & 2 deletions packages/react/src/components/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ export default class Search extends Component {

const CloseIconX = size === 'xl' ? Close20 : Close16;

const searchId = `${id}-search`;

return (
<div className={searchClasses}>
<div role="search" aria-labelledby={searchId} className={searchClasses}>
<Search16 className={`${prefix}--search-magnifier`} />
<label htmlFor={id} className={`${prefix}--label`}>
<label id={searchId} htmlFor={id} className={`${prefix}--label`}>
{labelText}
</label>
<input
Expand Down

0 comments on commit 7e4c0e5

Please sign in to comment.