Open forjuan opened 6 years ago
This is a very frustrating bug! It means that modal.close()
is unsafe! Now we have to guard against it?! Especially since the modal can close itself which means if you code calls close from an action hook your screwed!
I use a work around to handle this use case. It uses a Confirmer object to handle the complexity as follows:
function openModal() {
return new Confirmer(resolver => {
let inst = $('[data-remodal-id=modal]').remodal();
let promise = inst.open();
resolver.dispose(() => {
return promise.then(() => {
let modalState = inst.getState();
// https://github.com/vodkabears/Remodal/issues/291
if (modalState !== 'opened') { return; }
return inst.close();
});
});
});
}
I should not close modal twice, but I really did. Then I found I can't open remodal again. Finally I found animationend event can't be triggered when wrapper element's value of display attribute is none, so the wrapper state will be closing and never change back. maybe can set hidden to the value of wrapper's visibility attribute to solve this problem.
` Remodal.prototype.close = function(reason) { var remodal = this;
};`