Skip to content

Commit b7abe20

Browse files
authored
fix(datatable): remove toolbar search and menu from tab order (#14397)
* fix(datatable): remove toolbar search and menu from tab order when batch actions are open * chore: update snaps
1 parent f389dfa commit b7abe20

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

e2e/components/DataTable/DataTable-test.avt.e2e.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ test.describe('DataTable @avt', () => {
154154
await page.keyboard.press('Shift+Tab');
155155
await page.keyboard.press('Shift+Tab');
156156
await page.keyboard.press('Shift+Tab');
157-
await page.keyboard.press('Shift+Tab');
158-
await page.keyboard.press('Shift+Tab');
159157

160158
await page
161159
.getByRole('heading', { name: 'Expandable row content' })

packages/react/src/components/DataTable/__tests__/__snapshots__/DataTable-test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ exports[`DataTable behaves as expected selection should render and match snapsho
515515
id="custom-id"
516516
placeholder="Filter table"
517517
role="searchbox"
518+
tabindex="0"
518519
type="text"
519520
value=""
520521
/>
@@ -941,6 +942,7 @@ exports[`DataTable renders as expected - Component API should render and match s
941942
id="custom-id"
942943
placeholder="Filter table"
943944
role="searchbox"
945+
tabindex="0"
944946
type="text"
945947
value=""
946948
/>

packages/react/src/components/DataTable/__tests__/__snapshots__/TableToolbarSearch-test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ exports[`TableToolbarSearch renders as expected - Component API should render 1`
4040
id="custom-id"
4141
placeholder="Filter table"
4242
role="searchbox"
43+
tabindex="0"
4344
type="text"
4445
value=""
4546
/>

packages/react/src/components/DataTable/stories/dynamic-content/DataTable-dynamic-content.stories.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,16 @@ export const Default = () => {
154154
</TableBatchAction>
155155
</TableBatchActions>
156156
<TableToolbarContent>
157-
<TableToolbarSearch onChange={onInputChange} />
158-
<TableToolbarMenu>
157+
<TableToolbarSearch
158+
tabIndex={
159+
batchActionProps.shouldShowBatchActions ? -1 : 0
160+
}
161+
onChange={onInputChange}
162+
/>
163+
<TableToolbarMenu
164+
tabIndex={
165+
batchActionProps.shouldShowBatchActions ? -1 : 0
166+
}>
159167
<TableToolbarAction onClick={this.handleOnRowAdd}>
160168
Add row
161169
</TableToolbarAction>
@@ -328,8 +336,14 @@ export const Playground = (args) => {
328336
action('TableToolbarSearch - onChange')(evt);
329337
onInputChange(evt);
330338
}}
339+
tabIndex={
340+
batchActionProps.shouldShowBatchActions ? -1 : 0
341+
}
331342
/>
332-
<TableToolbarMenu>
343+
<TableToolbarMenu
344+
tabIndex={
345+
batchActionProps.shouldShowBatchActions ? -1 : 0
346+
}>
333347
<TableToolbarAction
334348
onClick={(evt) => {
335349
action('handleOnRowAdd')(evt);

packages/react/src/components/Search/Search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(function Search(
243243
{labelText}
244244
</label>
245245
<input
246-
{...rest}
247246
autoComplete={autoComplete}
248247
className={`${prefix}--search-input`}
249248
defaultValue={defaultValue}
@@ -257,6 +256,7 @@ const Search = React.forwardRef<HTMLInputElement, SearchProps>(function Search(
257256
type={type}
258257
value={value}
259258
tabIndex={onExpand && !isExpanded ? -1 : undefined}
259+
{...rest}
260260
/>
261261
<button
262262
aria-label={closeButtonLabelText}

0 commit comments

Comments
 (0)