Merge pull request 'fix: fill location from autocomplete (#71)' (#72) from feature/order-form-upgrade into main
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
Reviewed-on: #72 Reviewed-by: Primakov Alexandr Alexandrovich <primakovpro@gmail.com>
This commit is contained in:
commit
e3d316c418
@ -42,6 +42,13 @@ export const LocationInput = memo(
|
|||||||
|
|
||||||
const onInputChange: InputProps['onChange'] = async (e) => {
|
const onInputChange: InputProps['onChange'] = async (e) => {
|
||||||
const newInputValue = e.target.value;
|
const newInputValue = e.target.value;
|
||||||
|
|
||||||
|
if (
|
||||||
|
isValidLocation(newInputValue) &&
|
||||||
|
(await isRealLocation(ymaps, newInputValue))
|
||||||
|
) {
|
||||||
|
onChange(newInputValue);
|
||||||
|
} else {
|
||||||
setInputValue(newInputValue);
|
setInputValue(newInputValue);
|
||||||
|
|
||||||
if (newInputValue.trim().length > 3) {
|
if (newInputValue.trim().length > 3) {
|
||||||
@ -57,6 +64,7 @@ export const LocationInput = memo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFocus: InputProps['onFocus'] = () => {
|
const onFocus: InputProps['onFocus'] = () => {
|
||||||
@ -103,7 +111,7 @@ export const LocationInput = memo(
|
|||||||
{...props}
|
{...props}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
value={inputValue}
|
value={inputValue ?? value}
|
||||||
onChange={onInputChange}
|
onChange={onInputChange}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
placeholder={t('placeholder')}
|
placeholder={t('placeholder')}
|
||||||
|
Loading…
Reference in New Issue
Block a user