Closed imjoeco closed 9 years ago
How does this interact with #640? Can we merge both?
I included the changes from this PR in #640 when #644 was closed without realizing @imjoeco was planning to open a new PR with the same changes. I can revert d37786b1c8f39b173f5ef3ef89f3a1bff7b23d7d so that this PR can be merged or you can just accept both PRs as is though this PR has the same changes as d37786b1c8f39b173f5ef3ef89f3a1bff7b23d7d.
@gakimball Let me know how you want to handle it.
The checks that soumak77 added in 640 shouldn't conflict, but when changing the setTimeout to $timeout and invoking the function immediately, the safeguards that soumak77 added don't appear necessary as they seemed to be the byproduct of working with a stale scope state. Not sure whether or not it's better with soumak77's safeguard fix as the scope and element variables not being available to the destroy function appears to be a bug that the safeguards would stop the app from correctly erroring on.
The issue with modal close (including scope and element variables sometimes being undefined as noted in @soumak77's pr) seems to be stemming from the use of setTimeout with a 3 second delay instead of $timeout with no delay. Using $timeout without a delay also eliminates errors when trying to destroy modals immediately before redrawing them which appears necessary when changing the content scope of modals created using ModalFactory.