diff --git a/src/SelectInput/Input.tsx b/src/SelectInput/Input.tsx index 8c12606a..13609605 100644 --- a/src/SelectInput/Input.tsx +++ b/src/SelectInput/Input.tsx @@ -162,7 +162,7 @@ const Input = React.forwardRef((props, ref) => { // Extract shared input props const sharedInputProps = { id, - type: mode === 'combobox' ? 'text' : 'search', + type: 'text', ...restProps, ref: inputRef as React.Ref, style: { @@ -171,7 +171,7 @@ const Input = React.forwardRef((props, ref) => { '--select-input-width': widthCssVar, } as React.CSSProperties, autoFocus, - autoComplete: autoComplete || 'off', + autoComplete: autoComplete || 'new-password', className: inputCls, disabled, value: value || '', diff --git a/tests/Accessibility.test.tsx b/tests/Accessibility.test.tsx index 978ddd9d..a7df5837 100644 --- a/tests/Accessibility.test.tsx +++ b/tests/Accessibility.test.tsx @@ -285,6 +285,9 @@ describe('Select.Accessibility', () => { const input = container.querySelector('input'); expect(input).toHaveAttribute('role', 'combobox'); + // https://github.com/ant-design/ant-design/issues/57904 + expect(input).toHaveAttribute('type', 'text'); + expect(input).not.toHaveAttribute('list'); expect(input).toHaveAttribute('aria-expanded', 'false'); expect(input).toHaveAttribute('aria-haspopup', 'listbox'); expect(input).not.toHaveAttribute('aria-owns'); diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 3cdf6128..4f573d60 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1426,14 +1426,16 @@ describe('Select.Basic', () => { expect(container.querySelector('.rc-select-item-empty').textContent).toEqual('Not Found'); }); - it('search input type', () => { + it('uses text input type and disables browser autocomplete for search', () => { const { container } = render( , ); - expect(container.querySelector('input').getAttribute('type')).toBe('search'); + const input = container.querySelector('input'); + expect(input.getAttribute('type')).toBe('text'); + expect(input.getAttribute('autocomplete')).toBe('new-password'); }); it('warns on invalid children', () => { diff --git a/tests/__snapshots__/Combobox.test.tsx.snap b/tests/__snapshots__/Combobox.test.tsx.snap index 4c1ae640..8e75469f 100644 --- a/tests/__snapshots__/Combobox.test.tsx.snap +++ b/tests/__snapshots__/Combobox.test.tsx.snap @@ -17,7 +17,7 @@ exports[`Select.Combobox renders controlled correctly 1`] = ` aria-autocomplete="list" aria-expanded="false" aria-haspopup="listbox" - autocomplete="off" + autocomplete="new-password" class="rc-select-input" id="test-id" role="combobox" @@ -45,7 +45,7 @@ exports[`Select.Combobox renders correctly 1`] = ` aria-autocomplete="list" aria-expanded="false" aria-haspopup="listbox" - autocomplete="off" + autocomplete="new-password" class="rc-select-input" id="test-id" role="combobox" diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 7d7c0edc..0b62ff9b 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -123,11 +123,11 @@ exports[`Select.Basic render renders aria-attributes correctly 1`] = ` aria-haspopup="listbox" aria-label="some-label" aria-labelledby="test-id" - autocomplete="off" + autocomplete="new-password" class="antd-input" id="test-id" role="combobox" - type="search" + type="text" value="" /> @@ -152,11 +152,11 @@ exports[`Select.Basic render renders correctly 1`] = ` aria-autocomplete="list" aria-expanded="false" aria-haspopup="listbox" - autocomplete="off" + autocomplete="new-password" class="antd-input" id="test-id" role="combobox" - type="search" + type="text" value="" /> @@ -183,11 +183,11 @@ exports[`Select.Basic render renders data-attributes correctly 1`] = ` aria-autocomplete="list" aria-expanded="false" aria-haspopup="listbox" - autocomplete="off" + autocomplete="new-password" class="antd-input" id="test-id" role="combobox" - type="search" + type="text" value="" /> @@ -212,12 +212,12 @@ exports[`Select.Basic render renders disabled select correctly 1`] = ` aria-autocomplete="list" aria-expanded="false" aria-haspopup="listbox" - autocomplete="off" + autocomplete="new-password" class="antd-input" disabled="" id="test-id" role="combobox" - type="search" + type="text" value="" /> @@ -239,11 +239,11 @@ exports[`Select.Basic render renders role prop correctly 1`] = ` aria-autocomplete="list" aria-expanded="false" aria-haspopup="listbox" - autocomplete="off" + autocomplete="new-password" class="antd-input" id="test-id" role="button" - type="search" + type="text" value="" /> diff --git a/tests/__snapshots__/Tags.test.tsx.snap b/tests/__snapshots__/Tags.test.tsx.snap index c19b95bb..73b3d645 100644 --- a/tests/__snapshots__/Tags.test.tsx.snap +++ b/tests/__snapshots__/Tags.test.tsx.snap @@ -65,12 +65,12 @@ exports[`Select.Tags OptGroup renders correctly 1`] = ` aria-expanded="true" aria-haspopup="listbox" aria-owns="test-id_list" - autocomplete="off" + autocomplete="new-password" class="rc-select-input" id="test-id" role="combobox" style="--select-input-width: 0;" - type="search" + type="text" value="" /> diff --git a/tests/__snapshots__/ssr.test.tsx.snap b/tests/__snapshots__/ssr.test.tsx.snap index 2536b751..9f1c6c0f 100644 --- a/tests/__snapshots__/ssr.test.tsx.snap +++ b/tests/__snapshots__/ssr.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Select.SSR should work 1`] = `"
"`; +exports[`Select.SSR should work 1`] = `"
"`;