Skip to content

Commit 6305fb2

Browse files
authored
[AlphaPicker] Remove autocomplete from SearchField props (#11836)
### WHY are these changes introduced? Quick api cleanup ### WHAT is this pull request doing? SearchField doesn't need the autocomplete prop
1 parent f55e5ad commit 6305fb2

File tree

7 files changed

+14
-22
lines changed

7 files changed

+14
-22
lines changed

polaris-react/playground/DetailsPage.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ export function DetailsPage() {
648648
searchField={{
649649
label: 'Search tags',
650650
placeholder: 'Search or add new tags',
651-
autoComplete: 'off',
652651
value: query,
653652
onChange: (value) => setQuery(value),
654653
}}
@@ -676,7 +675,6 @@ export function DetailsPage() {
676675
searchField={{
677676
label: 'Search vendors',
678677
placeholder: 'Search or add new vendor',
679-
autoComplete: 'off',
680678
value: query,
681679
onChange: (value) => setQuery(value),
682680
}}

polaris-react/src/components/Picker/Picker.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ import type {
1313
ComboboxListboxOptionType,
1414
} from '../../utilities/combobox';
1515
import {Box} from '../Box';
16-
import type {TextFieldProps} from '../TextField';
1716
import type {ListboxProps, OptionProps} from '../Listbox';
1817
import {Listbox} from '../Listbox';
1918
import type {IconProps} from '../Icon';
2019
import {Icon} from '../Icon';
2120
import {escapeRegex} from '../../utilities/string';
2221

2322
import {Activator, SearchField} from './components';
24-
import type {ActivatorProps} from './components';
23+
import type {SearchFieldProps, ActivatorProps} from './components';
2524

2625
export interface PickerProps extends Omit<ListboxProps, 'children'> {
2726
/** Configure the button that activates the Picker */
@@ -33,7 +32,7 @@ export interface PickerProps extends Omit<ListboxProps, 'children'> {
3332
/** Used to add a new picker option that isn't listed */
3433
addAction?: OptionProps & {icon?: IconProps['source']};
3534
/** TextField that allows filtering of options */
36-
searchField?: TextFieldProps;
35+
searchField?: SearchFieldProps;
3736
/** Whether or not more options are available to lazy load when the bottom of the listbox reached. Use the hasMoreResults boolean provided by the GraphQL API of the paginated data. */
3837
willLoadMoreOptions?: boolean;
3938
/** Height to set on the Popover Pane. */

polaris-react/src/components/Picker/components/SearchField/SearchField.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {Text} from '../../../Text';
88

99
import styles from './SearchField.module.css';
1010

11+
export type SearchFieldProps = Omit<TextFieldProps, 'autoComplete'>;
12+
1113
export function SearchField({
1214
value,
1315
id: idProp,
@@ -19,7 +21,7 @@ export function SearchField({
1921
prefix,
2022
placeholder,
2123
focused,
22-
}: TextFieldProps) {
24+
}: SearchFieldProps) {
2325
const inputRef = React.useRef<HTMLInputElement>(null);
2426
const comboboxTextFieldContext = useComboboxTextField();
2527

@@ -89,12 +91,13 @@ export function SearchField({
8991
className={styles.SearchField}
9092
value={value}
9193
type={type}
92-
aria-activedescendant={activeOptionId}
9394
role="combobox"
95+
placeholder={placeholder}
96+
autoComplete="off"
97+
aria-activedescendant={activeOptionId}
9498
aria-haspopup="listbox"
9599
aria-autocomplete="list"
96100
aria-expanded="true"
97-
placeholder={placeholder}
98101
aria-controls={listboxId}
99102
onFocus={handleFocus}
100103
onBlur={handleBlur}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export {SearchField} from './SearchField';
2+
export type {SearchFieldProps} from './SearchField';

polaris-react/src/components/Picker/components/SearchField/tests/SearchField.test.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ function mountWithProvider(
1717
<ComboboxTextFieldContext.Provider
1818
value={{...props.textFieldProviderValue}}
1919
>
20-
<SearchField
21-
label="label"
22-
onChange={noop}
23-
autoComplete="off"
24-
{...props.textFieldProps}
25-
/>
20+
<SearchField label="label" onChange={noop} {...props.textFieldProps} />
2621
</ComboboxTextFieldContext.Provider>,
2722
);
2823

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export {SearchField} from './SearchField';
1+
export * from './SearchField';
22
export * from './Activator';

polaris-react/src/components/Picker/tests/Picker.test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('<Picker />', () => {
2020
it('renders a SearchField', () => {
2121
const picker = mountWithApp(
2222
<Picker
23-
searchField={{label: 'Input', autoComplete: 'off'}}
23+
searchField={{label: 'Input'}}
2424
activator={{label: 'Choose something'}}
2525
/>,
2626
);
@@ -51,7 +51,7 @@ describe('<Picker />', () => {
5151
activator={{}}
5252
addAction={addAction}
5353
options={[{value: 'one', children: 'One'}]}
54-
searchField={{label: '', autoComplete: 'off'}}
54+
searchField={{label: ''}}
5555
/>,
5656
);
5757

@@ -68,11 +68,7 @@ describe('<Picker />', () => {
6868
];
6969

7070
const picker = mountWithApp(
71-
<Picker
72-
activator={{}}
73-
options={options}
74-
searchField={{label: '', autoComplete: 'off'}}
75-
/>,
71+
<Picker activator={{}} options={options} searchField={{label: ''}} />,
7672
);
7773

7874
picker.find('button')!.trigger('onClick');

0 commit comments

Comments
 (0)