Backdrop click crashes when opening child modal #534
Unanswered
mauricekindermann
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
This is likely because the modal hasn't finished the entire process of closing. One way would be to add a check that waits until the element is hidden. Not tested, but it could be something like: <button
x-data
x-on:click="openModalWhenHidden(() => $dispatch('openModal', { component: 'users' }))"
>
Show Users
</button>
<script>
function openModalWhenHidden(callback, retries = 3, delay = 500) {
const el = document.querySelector('.modal');
const visible = el && el.offsetParent !== null;
if (!visible) {
callback();
} else if (retries > 0) {
setTimeout(() => openModalWhenHidden(callback, retries - 1, delay), delay);
}
}
</script>So it will call |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! I was stress testing something I'm building and ran into a race condition I cannot solve:
https://www.loom.com/share/b2b661b8f07247c98577ce4de7e5af82
Environment: wire-elements/modal ^3.0, Laravel 12, Livewire 3
When you open a child modal and quickly click the backdrop (interuptting the child modal), the child modal flickers then crashes, and can only be fixed by a page refresh.
It's simple enough to reproduce:
I noticed at the bottom of this page (Demo Time) you have a Slide-Over example that uses a child compontent, and the dismiss seems to interupt it nicely.
https://wire-elements.dev/pro
The backdrop is not the direct issue - even if I disable the backdrop and use a Cancel button I can reproduce it, as shown in the video above.
Is this a limitation fo the free version, does Pro solve this with modals? Or is this an issue in both verisons? If Pro solves it I'll just buy it.
Thanks Philo!
Beta Was this translation helpful? Give feedback.
All reactions