Skip to content

Commit

Permalink
[AlphaPicker] Remove autocomplete from SearchField props (#11836)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

Quick api cleanup

### WHAT is this pull request doing?

SearchField doesn't need the autocomplete prop
  • Loading branch information
kyledurand authored Apr 18, 2024
1 parent f55e5ad commit 6305fb2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 22 deletions.
2 changes: 0 additions & 2 deletions polaris-react/playground/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ export function DetailsPage() {
searchField={{
label: 'Search tags',
placeholder: 'Search or add new tags',
autoComplete: 'off',
value: query,
onChange: (value) => setQuery(value),
}}
Expand Down Expand Up @@ -676,7 +675,6 @@ export function DetailsPage() {
searchField={{
label: 'Search vendors',
placeholder: 'Search or add new vendor',
autoComplete: 'off',
value: query,
onChange: (value) => setQuery(value),
}}
Expand Down
5 changes: 2 additions & 3 deletions polaris-react/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ import type {
ComboboxListboxOptionType,
} from '../../utilities/combobox';
import {Box} from '../Box';
import type {TextFieldProps} from '../TextField';
import type {ListboxProps, OptionProps} from '../Listbox';
import {Listbox} from '../Listbox';
import type {IconProps} from '../Icon';
import {Icon} from '../Icon';
import {escapeRegex} from '../../utilities/string';

import {Activator, SearchField} from './components';
import type {ActivatorProps} from './components';
import type {SearchFieldProps, ActivatorProps} from './components';

export interface PickerProps extends Omit<ListboxProps, 'children'> {
/** Configure the button that activates the Picker */
Expand All @@ -33,7 +32,7 @@ export interface PickerProps extends Omit<ListboxProps, 'children'> {
/** Used to add a new picker option that isn't listed */
addAction?: OptionProps & {icon?: IconProps['source']};
/** TextField that allows filtering of options */
searchField?: TextFieldProps;
searchField?: SearchFieldProps;
/** 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. */
willLoadMoreOptions?: boolean;
/** Height to set on the Popover Pane. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {Text} from '../../../Text';

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

export type SearchFieldProps = Omit<TextFieldProps, 'autoComplete'>;

export function SearchField({
value,
id: idProp,
Expand All @@ -19,7 +21,7 @@ export function SearchField({
prefix,
placeholder,
focused,
}: TextFieldProps) {
}: SearchFieldProps) {
const inputRef = React.useRef<HTMLInputElement>(null);
const comboboxTextFieldContext = useComboboxTextField();

Expand Down Expand Up @@ -89,12 +91,13 @@ export function SearchField({
className={styles.SearchField}
value={value}
type={type}
aria-activedescendant={activeOptionId}
role="combobox"
placeholder={placeholder}
autoComplete="off"
aria-activedescendant={activeOptionId}
aria-haspopup="listbox"
aria-autocomplete="list"
aria-expanded="true"
placeholder={placeholder}
aria-controls={listboxId}
onFocus={handleFocus}
onBlur={handleBlur}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {SearchField} from './SearchField';
export type {SearchFieldProps} from './SearchField';
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ function mountWithProvider(
<ComboboxTextFieldContext.Provider
value={{...props.textFieldProviderValue}}
>
<SearchField
label="label"
onChange={noop}
autoComplete="off"
{...props.textFieldProps}
/>
<SearchField label="label" onChange={noop} {...props.textFieldProps} />
</ComboboxTextFieldContext.Provider>,
);

Expand Down
2 changes: 1 addition & 1 deletion polaris-react/src/components/Picker/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export {SearchField} from './SearchField';
export * from './SearchField';
export * from './Activator';
10 changes: 3 additions & 7 deletions polaris-react/src/components/Picker/tests/Picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('<Picker />', () => {
it('renders a SearchField', () => {
const picker = mountWithApp(
<Picker
searchField={{label: 'Input', autoComplete: 'off'}}
searchField={{label: 'Input'}}
activator={{label: 'Choose something'}}
/>,
);
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('<Picker />', () => {
activator={{}}
addAction={addAction}
options={[{value: 'one', children: 'One'}]}
searchField={{label: '', autoComplete: 'off'}}
searchField={{label: ''}}
/>,
);

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

const picker = mountWithApp(
<Picker
activator={{}}
options={options}
searchField={{label: '', autoComplete: 'off'}}
/>,
<Picker activator={{}} options={options} searchField={{label: ''}} />,
);

picker.find('button')!.trigger('onClick');
Expand Down

0 comments on commit 6305fb2

Please sign in to comment.