Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "No results found" configurable via configs #490

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dev7ch
Copy link

@dev7ch dev7ch commented Mar 2, 2023

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

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

Disclaimer: not tested, just a "walk by fix", hopefully it fits
@mbardelmeijer
Copy link

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);
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants