Internally use React <Activity> for state preservation in Modals, Popovers, etc. #8365
christian-leingang
started this conversation in
Feature requests
Replies: 1 comment
-
|
+1 I'm currently using Mantine's tab component and it would be great to have |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I propose changing the internal implementation of these components to leverage the new
<Activity>component from React.Instead of conditionally rendering the children (which causes unmounting), Mantine could internally wrap the
childrenofModal,Popover,Dialog, etc., in an<Activity>component. Themodeof this component would be toggled based on theopenedprop.A simplified conceptual implementation for the
Modalcomponent might look like this:This would hide the content via
display: "none"instead of unmounting it, thereby preserving its entire React state and the corresponding DOM state (like input values or scroll positions).Benefits of this approach
ModalorPopoverwould be preserved across open/close cycles out-of-the-box. This is a huge UX win for forms and complex interactive content.<Activity>allows for pre-rendering. Content can be rendered in a hidden state (mode='hidden') and be ready to display instantly, which can make the UI feel more responsive.Potential for an Opt-Out
This behavior could be introduced as the new default. Alternatively, to avoid breaking changes or for cases where resetting the state is desired, it could be controlled via a new prop, for example
keepMountedorpreserveState.This would provide maximum flexibility.
I believe this internal change would be a powerful enhancement for Mantine and would solve a common pain point for many developers. What are your thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions