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

Add a keepMounted option #87

Open
FrameMuse opened this issue Mar 29, 2023 · 4 comments
Open

Add a keepMounted option #87

FrameMuse opened this issue Mar 29, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@FrameMuse
Copy link
Owner

FrameMuse commented Mar 29, 2023

Motivation

By default, all modals continue to be mounted even when they are closed. Despite of that it's giving some advantages, sometimes it may be required to unmount it.

For example, the modal can contain a state machine that will continue working after closure, which may be unintentional.

Description

keepMounted will be added to ModalParams, so developers can disable it for single modal or all modals by default.

Example 1

Modal.open(Component, { keepMounted: false })

Example 2

const Modal = new ModalController({
  default: { keepMounted: false }
})
Modal.open(Component)

These two modals will have the same behavior.

@FrameMuse FrameMuse added the enhancement New feature or request label Mar 29, 2023
@FrameMuse FrameMuse self-assigned this Mar 29, 2023
@FrameMuse FrameMuse changed the title Add keepMounted Add keepMounted to ModalParams Mar 29, 2023
@FrameMuse FrameMuse added this to the v1.3.0 milestone Mar 29, 2023
@FrameMuse
Copy link
Owner Author

This is related to caching.

@FrameMuse FrameMuse removed this from the v1.3.0 milestone May 20, 2023
@FrameMuse FrameMuse changed the title Add keepMounted to ModalParams Implement keepMounted" Nov 28, 2023
@FrameMuse FrameMuse changed the title Implement keepMounted" Implement keepMounted Nov 28, 2023
@FrameMuse FrameMuse added this to the v3.0.0 milestone Nov 28, 2023
@FrameMuse FrameMuse changed the title Implement keepMounted Implement keepMounted and unmount Nov 29, 2023
@FrameMuse FrameMuse changed the title Implement keepMounted and unmount Add a keepMounted option Apr 4, 2024
@dientuki
Copy link

Hi! I really really need that feature, how can i help?

@FrameMuse
Copy link
Owner Author

@dientuki Hi, sorry for a late response, I actually wanted to work on this feature when new React Visibility API is fully there.

But we can start working on it now.

What we need is to make sure the component is mounted while not visible, we can probably use hidden attribute or display: none style.

But this feature will be a breaking change since, it makes ANY component to be always mounted, so I believe we should set keepMounted to false by default.

  • If this is overridden to true in the default settings, it should keep mounted all open components
  • If this is overridden to true in the local open params, it should keep mounted the opened component

Hope this helps, I'm currently busy with other staff, so hope you'll figure out how to implement this yourself. I will try to review the PR ASAP.

@FrameMuse
Copy link
Owner Author

FrameMuse commented Aug 25, 2024

Related to #258

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

No branches or pull requests

2 participants