Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Bug fixes

- Added an outline on `Banner` for Windows high contrast mode ([#2878](https://github.com/Shopify/polaris-react/pull/2878))
- Fixed Autocomplete / ComboBox focus ([#1089](https://github.com/Shopify/polaris-react/issues/1089))

### Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export function ComboBox({
aria-haspopup
onFocus={forcePopoverActiveTrue}
onBlur={handleBlur}
tabIndex={0}
tabIndex={options.length === 0 ? -1 : 0}
>
<KeypressListener keyCode={Key.DownArrow} handler={selectNextOption} />
<KeypressListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ describe('<ComboBox/>', () => {
expect(optionListOptions[1].value).toBe('macaroni_pizza');
expect(optionListOptions[1].label).toBe('Macaroni Pizza');
});

it.each([
[options, 0],
[[], -1],
])('sets tabIndex depending of number of options', (options, tabIndex) => {
const comboBox = mountWithApp(
<ComboBox
options={options}
selected={[]}
textField={renderTextField()}
onSelect={noop}
/>,
);

expect(comboBox.find('div', {role: 'combobox'})).toHaveReactProps({
tabIndex,
});
});
});

describe('contentBefore and contentAfter', () => {
Expand Down