You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the search toolbar (e.g. with lizmap search) do you think it would be a good idea to replace the current content inside the search toolbar by the text content from the result clicked by the user ?
Exemple :
a user search the parcel AB145 and start typing AB14
many results are displayed in the search toolbar (e.g. AB14, AB142, AB145, AB146)
the user clicks on AB145 but the content in the search toolbar is still AB14
My suggestion is to replace AB14 by the text clicked by the user (AB145)
The text was updated successfully, but these errors were encountered:
arno974
changed the title
The search toolbar should be replaced by the clicked result
The search toolbar content should be replaced by the clicked result
Nov 20, 2024
Hi, I have implemented a fix for this issue by ensuring that when a user clicks on a search result, the search bar content is updated dynamically. The solution uses a modular JavaScript class with event delegation for performance optimization. It also includes error handling to prevent crashes.
init() {
if (!this.searchInput) {
console.error("Search input field not found!");
return;
}
this.addResultClickListeners();
}
addResultClickListeners() {
document.addEventListener("click", (event) => {
const clickedElement = event.target.closest(this.searchResultSelector);
if (clickedElement) {
this.updateSearchBar(clickedElement.textContent.trim());
}
});
}
updateSearchBar(value) {
this.searchInput.value = value;
}
}
// Initialize the search updater for Lizmap
document.addEventListener("DOMContentLoaded", () => {
new LizmapSearchUpdater("#lizmapSearchInput", ".lizmap-search-result");
});
When using the search toolbar (e.g. with lizmap search) do you think it would be a good idea to replace the current content inside the search toolbar by the text content from the result clicked by the user ?
Exemple :
The text was updated successfully, but these errors were encountered: