Finsweet Modal JS is broken on Safari

Hi! I’m encountering an issue with closing a modal in Safari. When I click on ‘close,’ the modal pops right back up. Additionally, clicking on ‘close’ again doesn’t do anything.

This is happening only in Safari, works fine in Chrome.

Even the example “Modal 2 - JS” has this issue.

2 Likes

Thanks for the headsup @ravi.koomera! A bug report is already open! :muscle:

2 Likes

Thanks, Luis! What’s the estimated timeframe for resolving the issue?

2 Likes

I’m afraid we have no ETA but should be soon as we are about to release Attributes V2.

This script will work! It took two minutes with chagGPT so a little bit of a bummer the finsweet team couldn’t fix it :confused:

In this code .modal is the finsweet modal popup element that’s hidden by default

<script>
  // Ensure the modal script is loaded first
  (() => {
    var t = "https://cdn.jsdelivr.net/npm/@finsweet/attributes-modal@1/modal.js",
        e = document.querySelector(`script[src="${t}"]`);
    if (!e) {
      e = document.createElement("script");
      e.async = !0;
      e.src = t;
      document.head.append(e);
    }
  })();

  // Add event listener to force close the modal
  document.addEventListener("DOMContentLoaded", () => {
    // Function to close the modal
    const forceCloseModal = () => {
      const modal = document.querySelector('.modal');
      if (modal) {
        modal.style.display = 'none';
      }
    };

    // Attach the force close function to the modal close button
    const closeButton = document.querySelector('.modal-close');
    if (closeButton) {
      closeButton.addEventListener('click', forceCloseModal);
    }

    // Attach the force close function to the modal cover
    const modalCover = document.querySelector('.fs_modal-2_cover');
    if (modalCover) {
      modalCover.addEventListener('click', forceCloseModal);
    }

    // Optional: Automatically close the modal after a certain time (e.g., 5 seconds)
    // setTimeout(forceCloseModal, 5000);
  });
</script>

Hey @jakeschlegel86! Thanks for sharing the script! As previously mentioned we have an open bug report for this issue. However, we are prioritizing the development of fs-list for the initial release of Attributes V2.

I will let the team know of your solution so we can fix this ASAP :slight_smile: