Replies: 6 comments
-
Came here for this. +1. Not sure of the best way to implement it, so had not solved it yet - but I like your solution @seabasss. |
Beta Was this translation helpful? Give feedback.
-
I don't think this is possible. The closeModalOnEscape is handled by alpine. A 'modal attribute' is set for the component (from a static method call) when the new livewire modal component class is created. When the escape button is pressed an alpinejs method is called that reads the value of this modal attribute to decide whether to close or not. There are ways however that you could change one of these modal attributes after the class is created. You could fire an event that the main modal class is listening to. Something like below that passes the name of the component, the attribute you want to change, and the value of the attribute. The listener would then find the modal component and update the attribute value.
You would then have to implement some logic in your modal component class around when to fire this event. I guess you could go further by adding a method in the ModalComponent.php class
You could then call the following in your class that extends ModalComponent
to update the property I'll try and submit a PR when I get time. |
Beta Was this translation helpful? Give feedback.
-
Thanks, that would be amazing! :) |
Beta Was this translation helpful? Give feedback.
-
Did you ever get a chance to try this out? Thank you! :) |
Beta Was this translation helpful? Give feedback.
-
Checking in on this. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello, has there been any progress on this? I'm currently facing an issue with a third party select component being embedded inside a wire-elements modal. The issue is that clicking outside the open select will close the modal as well, and not just the select component. |
Beta Was this translation helpful? Give feedback.
-
Is there any way to let you close the modal by clicking outside or pressing escape, but only if nothing has changed in the form?
Would be cool to do something like this:
Or let you show another modal saying "You have unsaved changes. Are you sure you want to close the modal?" if the form is dirty.
Any ideas? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions