diff --git a/components/Forms/BookingWidget/FormContent/Search/index.tsx b/components/Forms/BookingWidget/FormContent/Search/index.tsx index c3de24662..109af79a3 100644 --- a/components/Forms/BookingWidget/FormContent/Search/index.tsx +++ b/components/Forms/BookingWidget/FormContent/Search/index.tsx @@ -48,13 +48,10 @@ export default function Search({ locations }: SearchProps) { dispatch({ type: ActionType.CLEAR_HISTORY_LOCATIONS }) } - function handleOnChange( - evt: FormEvent | ChangeEvent - ) { - const value = evt.currentTarget.value - if (value) { + function dispatchInputValue(inputValue: string) { + if (inputValue) { dispatch({ - payload: { search: value }, + payload: { search: inputValue }, type: ActionType.SEARCH_LOCATIONS, }) } else { @@ -62,6 +59,14 @@ export default function Search({ locations }: SearchProps) { } } + function handleOnChange( + evt: FormEvent | ChangeEvent + ) { + const newValue = evt.currentTarget.value + setValue(name, newValue) + dispatchInputValue(value) + } + function handleOnFocus(evt: FocusEvent) { const searchValue = evt.currentTarget.value if (searchValue) { @@ -114,6 +119,7 @@ export default function Search({ locations }: SearchProps) { inputValue={value} itemToString={(value) => (value ? value.name : "")} onSelect={handleOnSelect} + onInputValueChange={(inputValue) => dispatchInputValue(inputValue)} > {({ closeMenu, diff --git a/components/Forms/BookingWidget/index.tsx b/components/Forms/BookingWidget/index.tsx index 8c9ccb48e..731e17033 100644 --- a/components/Forms/BookingWidget/index.tsx +++ b/components/Forms/BookingWidget/index.tsx @@ -65,11 +65,7 @@ export default function Form({ locations, type }: BookingWidgetFormProps) { id={formId} > - + ) diff --git a/types/components/form/bookingwidget.ts b/types/components/form/bookingwidget.ts index e655b8b59..997890ca3 100644 --- a/types/components/form/bookingwidget.ts +++ b/types/components/form/bookingwidget.ts @@ -14,7 +14,6 @@ export interface BookingWidgetFormProps { export interface BookingWidgetFormContentProps { locations: Locations formId: string - formState: FormState } export enum ActionType {