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

Is there any way to listen modal open or close? #50

Open
cotton123236 opened this issue Oct 5, 2023 · 2 comments · May be fixed by #55
Open

Is there any way to listen modal open or close? #50

cotton123236 opened this issue Oct 5, 2023 · 2 comments · May be fixed by #55

Comments

@cotton123236
Copy link

Great library! It makes building cmd tools super easy!
I recently got a situation when I use ninja-keys to work with my react project. I use global storage to store the state of ninja-keys, but I don't know when should I set the state to false and I couldn't find any eventListener to check modal is open ore close.
If there is any way to listen modal state will be great!

@tiagorangel2011
Copy link

You can create a interval of, like 5 milliseconds and check for the ninja.__visible variable

@tzmartin
Copy link

tzmartin commented Apr 1, 2024

In case someone needs a way to detect a ninja visible modal:

ninjaModal = document.querySelector('ninja-keys')
if (ninjaModal) {
    const el = ninjaModal.shadowRoot.querySelector('div')
    if (el && el.classList.contains('visible')) {
      return
    }
}

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