Skip to content

Commit f984767

Browse files
authored
Fix for tabIndex prop handling (#572)
* fix(tabindex): tabindex attribute is no longer set to the container <div> Wrong handling of the tabIndex prop #570 * style(space): removed extra space before comment in generate.tsx #570
1 parent 0852ef2 commit f984767

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

src/generate.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export default function generateSelector<
280280
notFoundContent = 'Not Found',
281281
optionLabelProp,
282282
backfill,
283+
tabIndex,
283284
getInputElement,
284285
getPopupContainer,
285286

tests/Multiple.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,23 @@ describe('Select.Multiple', () => {
443443

444444
expect(wrapper.find('Input').prop('editable')).toBeTruthy();
445445
});
446+
447+
it('correctly handles the `tabIndex` prop', () => {
448+
const wrapper = mount(
449+
<Select mode="multiple" options={[{ value: 'bamboo' }, { value: 'light' }]} tabIndex={0} />,
450+
);
451+
expect(
452+
wrapper
453+
.find('.rc-select')
454+
.getDOMNode()
455+
.getAttribute('tabindex'),
456+
).toBeNull();
457+
458+
expect(
459+
wrapper
460+
.find('input.rc-select-selection-search-input')
461+
.getDOMNode()
462+
.getAttribute('tabindex'),
463+
).toBe('0');
464+
});
446465
});

tests/Select.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,4 +1650,21 @@ describe('Select.Basic', () => {
16501650
.text(),
16511651
).toBe('Communicated');
16521652
});
1653+
1654+
it('correctly handles the `tabIndex` prop', () => {
1655+
const wrapper = mount(<Select tabIndex={0} />);
1656+
expect(
1657+
wrapper
1658+
.find('.rc-select')
1659+
.getDOMNode()
1660+
.getAttribute('tabindex'),
1661+
).toBeNull();
1662+
1663+
expect(
1664+
wrapper
1665+
.find('input.rc-select-selection-search-input')
1666+
.getDOMNode()
1667+
.getAttribute('tabindex'),
1668+
).toBe('0');
1669+
});
16531670
});

tests/Tags.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,21 @@ describe('Select.Tags', () => {
399399
expect(errSpy).not.toHaveBeenCalled();
400400
errSpy.mockRestore();
401401
});
402+
403+
it('correctly handles the `tabIndex` prop', () => {
404+
const wrapper = mount(<Select mode="tags" tabIndex={0} />);
405+
expect(
406+
wrapper
407+
.find('.rc-select')
408+
.getDOMNode()
409+
.getAttribute('tabindex'),
410+
).toBeNull();
411+
412+
expect(
413+
wrapper
414+
.find('input.rc-select-selection-search-input')
415+
.getDOMNode()
416+
.getAttribute('tabindex'),
417+
).toBe('0');
418+
});
402419
});

0 commit comments

Comments
 (0)