jantinnerezo / livewire-alert

SweetAlert2 wrapper for Livewire
https://livewire-alert.jantinnerezo.com
MIT License
710 stars 74 forks source link

Bootstrap 5 Modal issues #24

Closed tahirafridi closed 3 years ago

tahirafridi commented 3 years ago

I've problems, when I show modal and someone click the delete button, there I'm showing sweetalert confirmation dialogue. It asks for confirmation or cancel, no matter which button you click, then it show the disabled dark screen and nothing else. is there any work around or it is the bug? why my bootstrap modal closed but not properly with this alert dialog?

image image

See in the pictures, after clicking any button on dialog it shows the grey background disabled screen.

below is my code to show modal


window.addEventListener('showManageCollectionsModal', event => {
            var modal = new bootstrap.Modal(document.querySelector('#manage_collection_modal'), {
                keyboard: false
            });

            modal.show();
});
jantinnerezo commented 3 years ago

I see the parent of the confirmation dialog is a bootstrap 5 modal, I haven't tried it yet with css libraries that has built-in components like modals. This is more likely an issue with SweetAlert2 library itself but can you try adding tabindex="-1" to your bootstrap modal?

tahirafridi commented 3 years ago

tabindex="-1" already there, but somewhere I read that if I remove it, it will resolve the issue, but no luck so far.

jantinnerezo commented 3 years ago

So weird, did you provide callbacks for onConfirmed and onCancelled and register the callbacks as event listeners in your livewire component?

tahirafridi commented 3 years ago

Yes all done as in your document, everything works perfectly, except, if I click the ok/cancel button after the alert confirmation it just show me the dulled screen with slightly grey overlay colour. and none of the html elements active, I have to refresh the whole page to see the or click the html elements.

jantinnerezo commented 3 years ago

Did the parent modal closed first when you hit the delete and shows the confirmation dialog? or just right after you finally click yes or no?

tahirafridi commented 3 years ago

No I'm not closing the main modal, because in my main modal there is table and list of collections, there is 'edit' and 'delete' buttons in the modal inside html table. So if someone click delete button, I'm showing them sweetalert dialogue , he/she click delete or cancel, it should say thank you and close the sweetalert but I don't want to close the main modal, because its not a good user experience to close the main modal without their intention and then if they want to edit or delete another collection, they need to again click the show collections modal.

tahirafridi commented 3 years ago

Right now sweetalert is trying to close the modal, but it doesn't close properly and it leave something behind, thats why the screen still keep disabled.

jantinnerezo commented 3 years ago

Yeah agree with that, since you trigger opening the modal with Javascript not with Livewire public states, did you try adding wire:ignore this might be dom sniffing issues but I might be wrong with that, you can check if there's any log errors on dev console when you hit confirm or cancel.

tahirafridi commented 3 years ago

Yeah thanks for the hints, yes it works but with 'wire:ignore.self' without .self it showing me the main modal as empty table no records there. But if i put .self with ignore it working perfectly. Thanks!

jantinnerezo commented 3 years ago

Glad you make it work and found a workaround, let me know if you still have some issue.