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

Destroy modal? #3200

Closed
tmikaeld opened this issue Oct 17, 2015 · 18 comments
Closed

Destroy modal? #3200

tmikaeld opened this issue Oct 17, 2015 · 18 comments

Comments

@tmikaeld
Copy link

Seems it isn't documented and it isn't working?

http://jsfiddle.net/Ln57snr5/

@jlukic
Copy link
Member

jlukic commented Oct 17, 2015

Modal destroy does teardown correctly, I'm not sure why your example isnt working. I'll take a peek

@jlukic jlukic added this to the 2.1.x milestone Oct 17, 2015
@Wangable
Copy link

maybe u can write this at the beginning to 'solve' this problem:
$('body .modals').remove()

each time u write a .modal('show'), semantic will automatically add a

dom in , u can remove it before the next time u use modal.

@mariusk
Copy link

mariusk commented Apr 8, 2016

+1 for @Wangable's comment. This bug hit me in a React app I'm writing, where the modal stopped working after a component was unmounted and remounted again. The callbacks (onApprove etc) simply were not being called. The solution was to call remove on the modal in the componentWillUnmount method. Then everything seems to work as expected.

@JonathanRosado
Copy link

I encountered something very similar to what @mariusk describes. The modal eventually reaches a "dead" state where none of callbacks are called.

@jlukic jlukic modified the milestones: 2.1.9, 2.1.x Apr 22, 2016
@jlukic
Copy link
Member

jlukic commented May 1, 2016

The dimmer was not properly removing events in destroy. I've also modified the element namespace variable to make the code a little simpler to read.

@jlukic jlukic closed this as completed May 1, 2016
jlukic added a commit that referenced this issue May 1, 2016
@jlukic jlukic modified the milestones: 2.1.9, 2.2 May 4, 2016
@coolblabla
Copy link

coolblabla commented Jun 24, 2016

@jlukic http://jsfiddle.net/Ln57snr5/
still haven't fixed in next branch?

@franciscolourenco
Copy link

2.2.3 is still affected http://jsfiddle.net/y80eLgau/

@cyberbobs
Copy link

@jlukic 2.2.6 is affected too http://jsfiddle.net/k286azas/

@larvanitis
Copy link

This issue should be re-opened until properly fixed.

@IonutBajescu IonutBajescu reopened this Oct 29, 2016
@isawk
Copy link

isawk commented Nov 5, 2016

we used an if/else statement to manage the modal, this way if it was ever created we just execute model("show") else it is created from scratch.

if (typeof mdlComponentVar != 'undefined'){
//show if we had already created before     
 mdlComponentVar.modal( "show" );
}else {
//create otherwise
  var mdlComponentVar = ...
}

@tmikaeld tmikaeld modified the milestones: 2.2.7, 2.2 Nov 7, 2016
@jlukic
Copy link
Member

jlukic commented Nov 7, 2016

I'll revisit this issue.

@paradissimon
Copy link

Yes please properly fix this. When the modal is closed, I'd like to have them totally removed from the DOM. I am creating them dynamically in a SPA app and can't afford to leak/have multiple instance of the same dialog lying around.

@jlukic
Copy link
Member

jlukic commented Dec 29, 2016

Since the modal DOM is not created from initialize it would be unexpected for it to be removed from DOM on destroy.

I think a solution similar to @isawk above makes sense to me, and is similar to what I currently do in my implementation on private projects.

If anyone has suggestions for how SUI can handle this without causing unexpected behaviors for people who arent using libs with tightly managed lifecycle i'd be willing to listen

@paradissimon
Copy link

paradissimon commented Dec 29, 2016 via email

@nix1
Copy link

nix1 commented Jan 4, 2017

Since the modal DOM is not created from initialize it would be unexpected for it to be removed from DOM on destroy.

@jlukic Perhaps not removed, but since the original DOM is modified, can I get it back to the initial state?
I easily end up with an empty active dimmer, which was not there initially.

@geemang2000
Copy link

This still seems to be a valid issue

@mariusk
Copy link

mariusk commented Aug 10, 2017

As my previous suggestion either did not work, or at some time stopped working, we did another look today to try to work around it. This time we found a workaround where we instead of explicitely calling hide, we return true from the onApprove method. Seems the state handling in the modal component gets a bit lost when we try to control showing and hiding explicitely.

@sido420
Copy link

sido420 commented Feb 8, 2018

This could become a breaking change for many apps, so whenever its implemented (if ever), we also need a boolean setting that tells Semantic not to destroy the DOM element on hide.

destory_on_hide: false

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

No branches or pull requests