Compare commits

..

No commits in common. "e3d316c418ed349182d8df5015bf672fe4b4aa2d" and "1471bf94dd5755f76adb66b146a3be1f4f34968a" have entirely different histories.

View File

@ -42,29 +42,21 @@ export const LocationInput = memo(
const onInputChange: InputProps['onChange'] = async (e) => {
const newInputValue = e.target.value;
setInputValue(newInputValue);
if (
isValidLocation(newInputValue) &&
(await isRealLocation(ymaps, newInputValue))
) {
onChange(newInputValue);
} else {
setInputValue(newInputValue);
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([]);
if (newInputValue.trim().length > 3) {
try {
const address = extractAddress(newInputValue);
const results = await ymaps.suggest(address);
setSuggestions(results);
} catch (error) {
console.error(error);
}
setIsSuggestionsPanelOpen(suggestions.length > 1);
} else {
setSuggestions([]);
}
setIsSuggestionsPanelOpen(suggestions.length > 1);
};
const onFocus: InputProps['onFocus'] = () => {
@ -111,7 +103,7 @@ export const LocationInput = memo(
{...props}
ref={ref}
onBlur={onBlur}
value={inputValue ?? value}
value={inputValue}
onChange={onInputChange}
onFocus={onFocus}
placeholder={t('placeholder')}