Skip to content

Fix for tabIndex prop handling #572

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

Merged
merged 4 commits into from
Dec 5, 2020
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 src/generate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export default function generateSelector<
notFoundContent = 'Not Found',
optionLabelProp,
backfill,
tabIndex,
getInputElement,
getPopupContainer,

Expand Down
19 changes: 19 additions & 0 deletions tests/Multiple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,23 @@ describe('Select.Multiple', () => {

expect(wrapper.find('Input').prop('editable')).toBeTruthy();
});

it('correctly handles the `tabIndex` prop', () => {
const wrapper = mount(
<Select mode="multiple" options={[{ value: 'bamboo' }, { value: 'light' }]} tabIndex={0} />,
);
expect(
wrapper
.find('.rc-select')
.getDOMNode()
.getAttribute('tabindex'),
).toBeNull();

expect(
wrapper
.find('input.rc-select-selection-search-input')
.getDOMNode()
.getAttribute('tabindex'),
).toBe('0');
});
});
17 changes: 17 additions & 0 deletions tests/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1650,4 +1650,21 @@ describe('Select.Basic', () => {
.text(),
).toBe('Communicated');
});

it('correctly handles the `tabIndex` prop', () => {
const wrapper = mount(<Select tabIndex={0} />);
expect(
wrapper
.find('.rc-select')
.getDOMNode()
.getAttribute('tabindex'),
).toBeNull();

expect(
wrapper
.find('input.rc-select-selection-search-input')
.getDOMNode()
.getAttribute('tabindex'),
).toBe('0');
});
});
17 changes: 17 additions & 0 deletions tests/Tags.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,21 @@ describe('Select.Tags', () => {
expect(errSpy).not.toHaveBeenCalled();
errSpy.mockRestore();
});

it('correctly handles the `tabIndex` prop', () => {
const wrapper = mount(<Select mode="tags" tabIndex={0} />);
expect(
wrapper
.find('.rc-select')
.getDOMNode()
.getAttribute('tabindex'),
).toBeNull();

expect(
wrapper
.find('input.rc-select-selection-search-input')
.getDOMNode()
.getAttribute('tabindex'),
).toBe('0');
});
});