Skip to content

Commit

Permalink
feat(Autocomplete): return clearAfterSelect and deprecate it
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcheremisin committed Aug 29, 2023
1 parent 2626386 commit 75624e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .changeset/soft-queens-eat.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@contentful/f36-autocomplete': minor
---

`clearAfterSelect` (`boolean`) replaced with `textOnAfterSelect` (`'clear' | 'preserve' | 'replace'`)
Add new props: `textOnAfterSelect?: 'clear' | 'preserve' | 'replace'`, `isOpen?: boolean; onOpen?: () => void; onClose?: () => void`, `inputValue?: string`
9 changes: 8 additions & 1 deletion packages/components/autocomplete/src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ export interface AutocompleteProps<ItemType>
* @default "replace"
*/
textOnAfterSelect?: 'clear' | 'preserve' | 'replace';
/**
* If this is set to `true` the text input will be cleared after an item is selected
* @default false
* @deprecated Use textOnAfterSelect="clear" instead
*/
clearAfterSelect?: boolean;
/**
* If this is set to `false` the dropdown menu will stay open after selecting an item
* @default true
Expand Down Expand Up @@ -180,7 +186,8 @@ function _Autocomplete<ItemType>(
onOpen,
id,
className,
textOnAfterSelect = 'replace',
clearAfterSelect = false,
textOnAfterSelect = clearAfterSelect ? 'clear' : 'replace',
closeAfterSelect = true,
defaultValue = '',
selectedItem,
Expand Down

0 comments on commit 75624e3

Please sign in to comment.