From 638c07a1047f6d7f94cadf95760abdbd84fe0c47 Mon Sep 17 00:00:00 2001 From: dennismorello Date: Wed, 25 Nov 2020 12:46:39 +0100 Subject: [PATCH 1/2] fix(tabindex): tabindex attribute is no longer set to the container
Wrong handling of the tabIndex prop #570 --- src/generate.tsx | 3 ++- tests/Multiple.test.tsx | 19 +++++++++++++++++++ tests/Select.test.tsx | 17 +++++++++++++++++ tests/Tags.test.tsx | 17 +++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/generate.tsx b/src/generate.tsx index e4bd8023b..fe8132f5e 100644 --- a/src/generate.tsx +++ b/src/generate.tsx @@ -188,7 +188,7 @@ export interface GenerateConfig { /** Convert single raw value into { label, value } format. Will be called by each value */ getLabeledValue: GetLabeledValue>; filterOptions: FilterOptions; - findValueOption:// Need still support legacy ts api + findValueOption: // Need still support legacy ts api | ((values: RawValueType[], options: FlattenOptionsType) => OptionsType) // New API add prevValueOptions support | (( @@ -278,6 +278,7 @@ export default function generateSelector< notFoundContent = 'Not Found', optionLabelProp, backfill, + tabIndex, getInputElement, getPopupContainer, diff --git a/tests/Multiple.test.tsx b/tests/Multiple.test.tsx index 12a31d5d9..2e2e784d9 100644 --- a/tests/Multiple.test.tsx +++ b/tests/Multiple.test.tsx @@ -443,4 +443,23 @@ describe('Select.Multiple', () => { expect(wrapper.find('Input').prop('editable')).toBeTruthy(); }); + + it('correctly handles the `tabIndex` prop', () => { + const wrapper = mount( + ); + expect( + wrapper + .find('.rc-select') + .getDOMNode() + .getAttribute('tabindex'), + ).toBeNull(); + + expect( + wrapper + .find('input.rc-select-selection-search-input') + .getDOMNode() + .getAttribute('tabindex'), + ).toBe('0'); + }); }); diff --git a/tests/Tags.test.tsx b/tests/Tags.test.tsx index caadf7c18..c95329fff 100644 --- a/tests/Tags.test.tsx +++ b/tests/Tags.test.tsx @@ -399,4 +399,21 @@ describe('Select.Tags', () => { expect(errSpy).not.toHaveBeenCalled(); errSpy.mockRestore(); }); + + it('correctly handles the `tabIndex` prop', () => { + const wrapper = mount(