Compare commits
No commits in common. "e3d316c418ed349182d8df5015bf672fe4b4aa2d" and "1471bf94dd5755f76adb66b146a3be1f4f34968a" have entirely different histories.
e3d316c418
...
1471bf94dd
@ -42,29 +42,21 @@ 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;
|
||||||
|
setInputValue(newInputValue);
|
||||||
|
|
||||||
if (
|
if (newInputValue.trim().length > 3) {
|
||||||
isValidLocation(newInputValue) &&
|
try {
|
||||||
(await isRealLocation(ymaps, newInputValue))
|
const address = extractAddress(newInputValue);
|
||||||
) {
|
const results = await ymaps.suggest(address);
|
||||||
onChange(newInputValue);
|
setSuggestions(results);
|
||||||
} else {
|
} catch (error) {
|
||||||
setInputValue(newInputValue);
|
console.error(error);
|
||||||
|
|
||||||
if (newInputValue.trim().length > 3) {
|
|
||||||
try {
|
|
||||||
const address = extractAddress(newInputValue);
|
|
||||||
const results = await ymaps.suggest(address);
|
|
||||||
setSuggestions(results);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setSuggestions([]);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
setSuggestions([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFocus: InputProps['onFocus'] = () => {
|
const onFocus: InputProps['onFocus'] = () => {
|
||||||
@ -111,7 +103,7 @@ export const LocationInput = memo(
|
|||||||
{...props}
|
{...props}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
value={inputValue ?? value}
|
value={inputValue}
|
||||||
onChange={onInputChange}
|
onChange={onInputChange}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
placeholder={t('placeholder')}
|
placeholder={t('placeholder')}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user