From 01bddca24e8f148d4c455710e7c0df95ab846f5d Mon Sep 17 00:00:00 2001 From: Abbey Hart Date: Wed, 12 Feb 2020 12:04:34 -0600 Subject: [PATCH 1/4] fix(search): switch search role from datatable to search, add labeledby --- .../DataTable/TableToolbarSearch.js | 1 - .../__snapshots__/DataTable-test.js.snap | 74 ++++++------------- .../TableBatchAction-test.js.snap | 11 +-- .../TableToolbarSearch-test.js.snap | 4 +- .../src/components/Search/Search-story.js | 18 +++-- .../react/src/components/Search/Search.js | 7 +- 6 files changed, 48 insertions(+), 67 deletions(-) diff --git a/packages/react/src/components/DataTable/TableToolbarSearch.js b/packages/react/src/components/DataTable/TableToolbarSearch.js index ba735e9f8baa..bf2c81b742ec 100644 --- a/packages/react/src/components/DataTable/TableToolbarSearch.js +++ b/packages/react/src/components/DataTable/TableToolbarSearch.js @@ -101,7 +101,6 @@ const TableToolbarSearch = ({ return (
onClick(event)} onFocus={event => handleExpand(event, true)} diff --git a/packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap b/packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap index 5d65c824dfe5..7c5b43fa4457 100644 --- a/packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap +++ b/packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap @@ -2019,7 +2019,7 @@ exports[`DataTable should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -2034,17 +2034,12 @@ exports[`DataTable should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - @@ -2091,7 +2086,7 @@ exports[`DataTable should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -2106,17 +2101,12 @@ exports[`DataTable should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - @@ -2163,7 +2153,7 @@ exports[`DataTable should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -2178,17 +2168,12 @@ exports[`DataTable should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - @@ -2245,7 +2230,6 @@ exports[`DataTable should render 1`] = ` onBlur={[Function]} onClick={[Function]} onFocus={[Function]} - role="search" tabIndex="0" >
Filter table @@ -3016,7 +3003,7 @@ exports[`DataTable sticky header should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -3031,17 +3018,12 @@ exports[`DataTable sticky header should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - @@ -3088,7 +3070,7 @@ exports[`DataTable sticky header should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -3103,17 +3085,12 @@ exports[`DataTable sticky header should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - @@ -3160,7 +3137,7 @@ exports[`DataTable sticky header should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -3175,17 +3152,12 @@ exports[`DataTable sticky header should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - @@ -3242,7 +3214,6 @@ exports[`DataTable sticky header should render 1`] = ` onBlur={[Function]} onClick={[Function]} onFocus={[Function]} - role="search" tabIndex="0" >
Filter table diff --git a/packages/react/src/components/DataTable/__tests__/__snapshots__/TableBatchAction-test.js.snap b/packages/react/src/components/DataTable/__tests__/__snapshots__/TableBatchAction-test.js.snap index 6e139bc633cc..6fcfa03bbf0d 100644 --- a/packages/react/src/components/DataTable/__tests__/__snapshots__/TableBatchAction-test.js.snap +++ b/packages/react/src/components/DataTable/__tests__/__snapshots__/TableBatchAction-test.js.snap @@ -42,7 +42,7 @@ exports[`DataTable.TableBatchAction should render 1`] = ` className="bx--btn__icon" height={16} preserveAspectRatio="xMidYMid meet" - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > @@ -59,17 +59,12 @@ exports[`DataTable.TableBatchAction should render 1`] = ` "willChange": "transform", } } - viewBox="0 0 32 32" + viewBox="0 0 16 16" width={16} xmlns="http://www.w3.org/2000/svg" > - diff --git a/packages/react/src/components/DataTable/__tests__/__snapshots__/TableToolbarSearch-test.js.snap b/packages/react/src/components/DataTable/__tests__/__snapshots__/TableToolbarSearch-test.js.snap index 2eccdb99d83f..cfb74f4268ff 100644 --- a/packages/react/src/components/DataTable/__tests__/__snapshots__/TableToolbarSearch-test.js.snap +++ b/packages/react/src/components/DataTable/__tests__/__snapshots__/TableToolbarSearch-test.js.snap @@ -14,7 +14,6 @@ exports[`DataTable.TableToolbarSearch should render 1`] = ` onBlur={[Function]} onClick={[Function]} onFocus={[Function]} - role="search" tabIndex="0" >
Filter table diff --git a/packages/react/src/components/Search/Search-story.js b/packages/react/src/components/Search/Search-story.js index 3464be4862aa..cc9e42c2f5c3 100644 --- a/packages/react/src/components/Search/Search-story.js +++ b/packages/react/src/components/Search/Search-story.js @@ -40,15 +40,23 @@ const props = () => ({ storiesOf('Search', module) .addDecorator(withKnobs) - .add('Default', () => , { - info: { - text: ` + .add( + 'Default', + () => ( +
+ +
+ ), + { + info: { + text: ` Search enables users to specify a word or a phrase to find particular relevant pieces of content without the use of navigation. Search can be used as the primary means of discovering content, or as a filter to aid the user in finding content. `, - }, - }) + }, + } + ) .add( '[Deprecated] custom buttons', () => ( diff --git a/packages/react/src/components/Search/Search.js b/packages/react/src/components/Search/Search.js index 4f08defba927..9f224b867ee9 100644 --- a/packages/react/src/components/Search/Search.js +++ b/packages/react/src/components/Search/Search.js @@ -162,9 +162,12 @@ export default class Search extends Component { const CloseIconX = size === 'xl' ? Close20 : Close16; return ( -
+
-