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 is always called regardless of options. #78

Open
michaeltford opened this issue Jul 2, 2023 · 2 comments
Open

destroy is always called regardless of options. #78

michaeltford opened this issue Jul 2, 2023 · 2 comments

Comments

@michaeltford
Copy link

disableAutoDestroy: false and destroyOnClose : false are not honored (at least not always).

https://github.com/Quernest/mui-modal-provider/blob/master/src/modal-provider.tsx#L165

The onExited should have an options (options.destroyOnClose || disableAutoDestroy) check before calling destroy?

@Quernest
Copy link
Owner

Quernest commented Jul 8, 2023

disableAutoDestroy: false and destroyOnClose : false are not honored (at least not always).

https://github.com/Quernest/mui-modal-provider/blob/master/src/modal-provider.tsx#L165

The onExited should have an options (options.destroyOnClose || disableAutoDestroy) check before calling destroy?

Hi @michaeltford, thank you for your comment :)

In the current implementation, the function show creates a unique key with a reference to the dialog component, its props, and options.

And the destroy function clears that key.

This is needed so that when opening/closing windows the state does not grow.

I don't see a problem with it. However, I have an interesting idea about reusing the key and optionally deleting it, for example, if the keepMounted prop is set to true

What do you think?

@michaeltford
Copy link
Author

michaeltford commented Sep 9, 2023

@Quernest, thank you for the response and sorry for the late response. I didn't realize that you had responded to me :-(.

I agree with your point about not wanting to grow and a keepMounted would be an alternative. I thought that is what disabledAutoDestory effective did. My use case is that I have a find dialog (that I don't want to unmount because it has a bunch of transient state) on hide.

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

No branches or pull requests

2 participants