From 06f43ee839393db9081ae1d40a8a400cebf29f92 Mon Sep 17 00:00:00 2001 From: Matthew Kalinin Date: Fri, 22 Nov 2024 17:45:21 +0300 Subject: [PATCH] Fixed behavior of suggest and route info --- src/controls/MMapRouteControl/MMapWaypointInput/index.ts | 5 ++++- src/controls/MMapRouteControl/index.ts | 9 ++++++--- src/controls/MMapSearchControl/MMapSuggest/index.ts | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/controls/MMapRouteControl/MMapWaypointInput/index.ts b/src/controls/MMapRouteControl/MMapWaypointInput/index.ts index bde3bf5..ee233dc 100644 --- a/src/controls/MMapRouteControl/MMapWaypointInput/index.ts +++ b/src/controls/MMapRouteControl/MMapWaypointInput/index.ts @@ -216,7 +216,10 @@ export class MMapWaypointInput extends mappable.MMapComplexEntity { this._isInputFocused = true; - this._suggestComponent.update({suggestNavigationAction: undefined}); + this._suggestComponent.update({ + searchInputValue: this.getValue(), + suggestNavigationAction: undefined + }); this._addDirectChild(this._suggestComponent); this._updateIndicatorStatus('focus'); }; diff --git a/src/controls/MMapRouteControl/index.ts b/src/controls/MMapRouteControl/index.ts index 760bb86..9371072 100644 --- a/src/controls/MMapRouteControl/index.ts +++ b/src/controls/MMapRouteControl/index.ts @@ -254,6 +254,7 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity { this._waypointInputFromElement.update({waypoint: null}); this._waypointInputToElement.update({waypoint: null}); + this._clearInfo(); + }; + + private _clearInfo = () => { this._routeInfoElement.replaceChildren(); if (this._routeInfoElement.parentElement === this._rootElement) { this._rootElement.removeChild(this._routeInfoElement); } - }; + } private _changeOrder = () => { const [fromOld, toOld] = this._waypoints; @@ -336,7 +341,6 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity { } private _updateSuggestList = async (searchInputValue: MMapSuggestProps['searchInputValue']) => { + this._removeSuggestItems(); + const suggestResult = (await this._props.suggest?.({text: searchInputValue, map: this.root})) ?? (await mappable.suggest({text: searchInputValue})); - this._removeSuggestItems(); - this._addSuggestItems(suggestResult, this._props.onSuggestClick); this._getSuggestElements().at(0)?.classList.add(ACTIVE_CLASS);