Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed behavior of suggest and route info #42

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/controls/MMapRouteControl/MMapWaypointInput/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ export class MMapWaypointInput extends mappable.MMapComplexEntity<MMapWaypointIn

private _onFocusInput = (_event: FocusEvent) => {
this._isInputFocused = true;
this._suggestComponent.update({suggestNavigationAction: undefined});
this._suggestComponent.update({
searchInputValue: this.getValue(),
suggestNavigationAction: undefined
});
this._addDirectChild(this._suggestComponent);
this._updateIndicatorStatus('focus');
};
Expand Down
9 changes: 6 additions & 3 deletions src/controls/MMapRouteControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity<MMapRouteControl
if (result === null) {
this._waypoints[waypointIndex] = null;
this._onUpdateWaypoints(null, waypointIndex);
this._clearInfo();
return;
}

Expand All @@ -275,11 +276,15 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity<MMapRouteControl
private _clearAll = () => {
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;
Expand Down Expand Up @@ -336,7 +341,6 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity<MMapRouteControl

this._routeInfoElement.classList.remove('mappable--route-control_info__error');
this._routeInfoElement.replaceChildren(createLoadingSpinner());

try {
const response = (await this._props.route?.({params, map: this.root})) ?? (await mappable.route(params));
const route = response[0].toRoute();
Expand Down Expand Up @@ -377,7 +381,6 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity<MMapRouteControl
});
const formattedLength = formatDistance(totalLength);
const formattedDuration = formatDuration(totalDuration);

return [
createInfoElementComponent('time', formattedDuration),
createInfoElementComponent('distance', formattedLength)
Expand Down
4 changes: 2 additions & 2 deletions src/controls/MMapSearchControl/MMapSuggest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class MMapSuggest extends mappable.MMapComplexEntity<MMapSuggestProps> {
}

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);
Expand Down
Loading