<Tab /> re-renders child pane on switching.
See original GitHub issueSteps
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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I would be OK supporting a single prop
renderActiveOnly
and default it totrue
so we have backward compatibility. Users can thenrenderActiveOnly={false}
to render every tab.Right now, we hard code the
active
className inTabPane.js
. This will now need to become a prop. TheTab.js
will then be able to choose to render all TabPanes and toggle theactive
prop or render a single Tab only (as it does currently).I managed to get my desired behavior working by using a combination of
<Menu />
and<Segment />
. I set the CSS visibility property of the Segments to toggle based on the active Menu Item. Still, a little roundabout way to achieve this behavior, but it works. Looking forward to having a prop enabling this OTB.Pasting code here for the benefit of anyone facing a similar issue with using
<Tab />
.JSX
CSS