-
Notifications
You must be signed in to change notification settings - Fork 4k
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
<Tab /> re-renders child pane on switching. #1877
Comments
This is expected behaviour, see this comment. I will left this open until @levithomason will response. |
@layershifter It seems that either behaviour (renderActiveOnly vs renderAll) could be justified based on the use case. If the use case involves heavy context switch penalty between tabs, renderActiveOnly behaviour would make Semantic UI unusable, and require careful unmounting/remounting support for Tab children. BlueprintJS implements a 'renderActiveTabPanelOnly' prop to support both behaviours. It would be nice to see something like this in Semantic UI's |
I managed to get my desired behavior working by using a combination of Pasting code here for the benefit of anyone facing a similar issue with using JSX
CSS
|
I would be OK supporting a single prop Right now, we hard code the |
A more adaptable quick-fix for the problem at hand starting from the implementation above. For this to work every child element put inside should have a name prop (which is used for the menu label).
Usage example
|
@chinoy Did #1976 resolve your issue with Leaflet, as in your example? Leaflet is why I searched for this issue as well, yet Leaflet appears to be not rendering correctly (zoomed all the way out) when rendered on an inactive tab. It works fine when the Leaflet tab is the first active tab. I.e. Works (Leaflet is up first):
Doesn't work (Leaflet is initially hidden):
|
Any solution for this?. I have tried renderActiveOnly={false} , but not working for me. |
Steps
The default behavior of the
<Tab />
component seems to be to remove it's active<Tab.Pane>
from the DOM every time it is made inactive, and to push it back in the DOM when it is selected and made active. This re-renders the child components of<Tab.Pane>
and is a problem if you have children like Leaflet or CesiumJS which internally manage their display state, as this state is reset on every re-render.Expected Result
One should expect that the default behavior would be to keep all Tab.Pane children rendered and in the DOM, and only display the one that is active. The inactive tabs should be hidden from the display while keeping them in the DOM.
Actual Result
Inactive Tabs get removed from the DOM and pushed in again when made active. This behavior breaks the flow of many stateful child components, by resetting their internal state.
Version
v0.71.0
Any quick fixes would be appreciated, while this gets fixed in main.
The text was updated successfully, but these errors were encountered: