From 75624e3f9a2550b7f6296fb0f3ec4362e41b3103 Mon Sep 17 00:00:00 2001 From: Max Cheremisin Date: Tue, 29 Aug 2023 12:03:04 +0200 Subject: [PATCH] feat(Autocomplete): return clearAfterSelect and deprecate it --- .changeset/soft-queens-eat.md | 2 +- packages/components/autocomplete/src/Autocomplete.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.changeset/soft-queens-eat.md b/.changeset/soft-queens-eat.md index a86c783da2..aa7fd336d8 100644 --- a/.changeset/soft-queens-eat.md +++ b/.changeset/soft-queens-eat.md @@ -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` diff --git a/packages/components/autocomplete/src/Autocomplete.tsx b/packages/components/autocomplete/src/Autocomplete.tsx index 15f4f9f0f0..939c294464 100644 --- a/packages/components/autocomplete/src/Autocomplete.tsx +++ b/packages/components/autocomplete/src/Autocomplete.tsx @@ -101,6 +101,12 @@ export interface AutocompleteProps * @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 @@ -180,7 +186,8 @@ function _Autocomplete( onOpen, id, className, - textOnAfterSelect = 'replace', + clearAfterSelect = false, + textOnAfterSelect = clearAfterSelect ? 'clear' : 'replace', closeAfterSelect = true, defaultValue = '', selectedItem,