Skip to content

Commit

Permalink
fix support for custom search and suggest (#25)
Browse files Browse the repository at this point in the history
1. I've thrown in custom `search` and `suggest` props
2. The `text` and `uri` properties now arrive in the search handler
  • Loading branch information
MokujinMap authored Jul 8, 2024
1 parent 69002fb commit 339397c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/controls/MMapRouteControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity<MMapRouteControl
inputPlaceholder: this._props.waypointsPlaceholders[waypointIndex],
waypoint,
geolocationTextInput: geolocationTextInput,
search: this._props.search,
suggest: this._props.suggest,
onSelectWaypoint: (result) => {
if (result === null) {
this._waypoints[waypointIndex] = null;
Expand Down
6 changes: 3 additions & 3 deletions src/controls/MMapSearchControl/MMapSuggest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class MMapSuggest extends mappable.MMapComplexEntity<MMapSuggestProps> {
element.classList.toggle(ACTIVE_CLASS, index === activeIndex);
});

if (suggestElements[activeIndex] && suggestElements[activeIndex]?.dataset?.title) {
this._props.setSearchInputValue(suggestElements[activeIndex].dataset.title);
if (suggestElements[activeIndex] && suggestElements[activeIndex]?.dataset?.text) {
this._props.setSearchInputValue(suggestElements[activeIndex].dataset.text);
}
};

Expand Down Expand Up @@ -222,7 +222,7 @@ class MMapSuggestItem extends mappable.MMapComplexEntity<MMapSuggestItemProps> {
this._rootElement.classList.add(SUGGEST_ITEM_CLASS);
this._rootElement.tabIndex = -1;
this._rootElement.addEventListener('click', this._props.onClick);
this._rootElement.dataset.title = this._props.suggestItem.title.text;
this._rootElement.dataset.text = this._props.suggestItem.title.text;
if (this._props.suggestItem?.uri) {
this._rootElement.dataset.uri = this._props.suggestItem.uri;
}
Expand Down

0 comments on commit 339397c

Please sign in to comment.