mapbox-gl-geocoder icon indicating copy to clipboard operation
mapbox-gl-geocoder copied to clipboard

Make "No results found" configurable via configs

Open dev7ch opened this issue 2 years ago • 1 comments

This should add a dynamic label for "No results found", related to #328

Disclaimer: not tested, just a walk by fix, hopefully it fits

  • [ ] briefly describe the changes in this PR
  • [ ] write tests for all new functionality
  • [ ] run npm run docs and commit changes to API.md
  • [ ] update CHANGELOG.md with changes under master heading before merging

dev7ch avatar Mar 02 '23 14:03 dev7ch

Would be great to have! We now have to resort to hacky mutation observer fixes:

(function () {
    // Create a new MutationObserver instance
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.type === 'childList') {
                var noResults = document.querySelector('.mapbox-gl-geocoder--no-results');
                if (noResults && noResults.innerText === "No results found") {
                    noResults.innerHTML = 'Geen resultaten gevonden.';
                }
            }
        });
    });

    // Select the target node for observing changes
    const targetNode = document.getElementsByClassName('suggestions')[0];

    // Set up the observer configuration
    const config = { childList: true, subtree: true };

    // Start observing the target node for configured mutations
    observer.observe(targetNode, config);
})();

mbardelmeijer avatar Dec 22 '23 13:12 mbardelmeijer