Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew44-mappable committed Jun 24, 2024
1 parent 08642d8 commit aad4211
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/controls/MMapRouteControl/MMapWaypointInput/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,21 @@ export class MMapWaypointInput extends mappable.MMapComplexEntity<MMapWaypointIn
protected _onDetach(): void {
this._detachDom?.();
this._detachDom = undefined;
this._removeDirectChild(this._suggestComponent);
}

private _updateIndicatorStatus(status: 'empty' | 'focus' | 'setted'): void {
this._indicator.innerHTML = '';
this._indicator.classList.toggle('mappable--route-control_waypoint-input__indicator_empty', status === 'empty');

switch (status) {
case 'empty':
this._indicator.insertAdjacentHTML('afterbegin', emptyIndicatorSVG);
this._indicator.innerHTML = emptyIndicatorSVG;
break;
case 'focus':
this._indicator.insertAdjacentHTML('afterbegin', focusIndicatorSVG);
this._indicator.innerHTML = focusIndicatorSVG;
break;
case 'setted':
this._indicator.insertAdjacentHTML('afterbegin', settedIndicatorSVG);
this._indicator.innerHTML = settedIndicatorSVG;
break;
}
}
Expand All @@ -196,7 +196,7 @@ export class MMapWaypointInput extends mappable.MMapComplexEntity<MMapWaypointIn
}, 200);

private _onFocusInput = (_event: FocusEvent) => {
this.addChild(this._suggestComponent);
this._addDirectChild(this._suggestComponent);
this._updateIndicatorStatus('focus');
};

Expand All @@ -206,7 +206,7 @@ export class MMapWaypointInput extends mappable.MMapComplexEntity<MMapWaypointIn
return;
}
if (event.relatedTarget !== this._suggestComponent.activeSuggest) {
this.removeChild(this._suggestComponent);
this._removeDirectChild(this._suggestComponent);
}
if (event.relatedTarget === this._locationButton) {
this._getGeolocation();
Expand All @@ -227,7 +227,7 @@ export class MMapWaypointInput extends mappable.MMapComplexEntity<MMapWaypointIn
}
const {uri, text} = this._suggestComponent.activeSuggest.dataset;
this._search({uri, text});
this.removeChild(this._suggestComponent);
this._removeDirectChild(this._suggestComponent);
this._inputEl.blur();
};

Expand Down
8 changes: 4 additions & 4 deletions src/controls/MMapSearchControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class MMapSearchCommonControl extends mappable.MMapComplexEntity<MMapSearchContr
private _updateSuggestComponent = () => {
if (this._searchInput.value) {
this._suggestComponent.update({searchInputValue: this._searchInput.value});
this.addChild(this._suggestComponent);
this._addDirectChild(this._suggestComponent);
} else {
this.removeChild(this._suggestComponent);
this._removeDirectChild(this._suggestComponent);
}
};

Expand All @@ -81,7 +81,7 @@ class MMapSearchCommonControl extends mappable.MMapComplexEntity<MMapSearchContr
} else if (event.type === 'blur') {
// add a check so that the function does not work if you click on the element of the suggest
if (event.relatedTarget !== this._suggestComponent?.activeSuggest) {
this.removeChild(this._suggestComponent);
this._removeDirectChild(this._suggestComponent);
}
}
};
Expand Down Expand Up @@ -209,7 +209,7 @@ class MMapSearchCommonControl extends mappable.MMapComplexEntity<MMapSearchContr
}

protected override _onDetach(): void {
this.removeChild(this._suggestComponent);
this._removeDirectChild(this._suggestComponent);
this._suggestComponent = undefined;

this._detachDom?.();
Expand Down

0 comments on commit aad4211

Please sign in to comment.