From 339397c2f4b2c37b76b87acb210ee943b30eb693 Mon Sep 17 00:00:00 2001 From: MokujinMap <162605427+MokujinMap@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:39:57 +0300 Subject: [PATCH] fix support for custom search and suggest (#25) 1. I've thrown in custom `search` and `suggest` props 2. The `text` and `uri` properties now arrive in the search handler --- src/controls/MMapRouteControl/index.ts | 2 ++ src/controls/MMapSearchControl/MMapSuggest/index.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controls/MMapRouteControl/index.ts b/src/controls/MMapRouteControl/index.ts index 7106b97..2bbe5f5 100644 --- a/src/controls/MMapRouteControl/index.ts +++ b/src/controls/MMapRouteControl/index.ts @@ -170,6 +170,8 @@ class MMapCommonRouteControl extends mappable.MMapComplexEntity { if (result === null) { this._waypoints[waypointIndex] = null; diff --git a/src/controls/MMapSearchControl/MMapSuggest/index.ts b/src/controls/MMapSearchControl/MMapSuggest/index.ts index 2f13952..304d705 100644 --- a/src/controls/MMapSearchControl/MMapSuggest/index.ts +++ b/src/controls/MMapSearchControl/MMapSuggest/index.ts @@ -77,8 +77,8 @@ class MMapSuggest extends mappable.MMapComplexEntity { 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); } }; @@ -222,7 +222,7 @@ class MMapSuggestItem extends mappable.MMapComplexEntity { 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; }