feat: Add keepMounted param to TabPanels for persisting panels when they are not active#2434
Conversation
…hey are not active
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new keepMounted prop to TabPanels that allows static panels to persist their component state when not active. The changes include re-exporting the new DHCTabPanels component, implementing the keepMounted logic within TabPanels, and adding unit tests to verify both persistent and non-persistent behaviors.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/components/src/spectrum/navigation.ts | Re-exports DHCTabPanels in place of Spectrum TabPanels |
| packages/components/src/spectrum/TabPanels.tsx | Implements keepMounted support using portal nodes |
| packages/components/src/spectrum/TabPanels.test.tsx | Adds tests validating both keepMounted and default behavior |
Files not reviewed (1)
- packages/components/package.json: Language not supported
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2434 +/- ##
==========================================
+ Coverage 47.06% 47.10% +0.03%
==========================================
Files 714 715 +1
Lines 39468 39505 +37
Branches 10063 9884 -179
==========================================
+ Hits 18576 18608 +32
- Misses 20881 20886 +5
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new keepMounted prop to the TabPanels component to enable persistent mounting of static panels. The changes include updating the navigation export to point to the new DHCTabPanels, implementing the DHCTabPanels component with portal logic to conditionally keep panels mounted, and adding unit tests covering both default and keepMounted behaviors.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/components/src/spectrum/navigation.ts | Updates export to wrap TabPanels with the new DHCTabPanels component. |
| packages/components/src/spectrum/TabPanels.tsx | Introduces DHCTabPanels with portal management for persisting panels. |
| packages/components/src/spectrum/TabPanels.test.tsx | Adds tests to verify both default and keepMounted behaviors. |
Files not reviewed (1)
- packages/components/package.json: Language not supported
Comments suppressed due to low confidence (1)
packages/components/src/spectrum/TabPanels.test.tsx:194
- [nitpick] Consider awaiting the waitFor call (e.g., using 'await waitFor(...)' in an async test) to ensure asynchronous assertions complete reliably.
waitFor(() => expect(onMount).toHaveBeenCalledTimes(1));
|
Found a potential (although probably extremely unlikely to happen) leak if using different keys to add new panels. Added a test to ensure components unmount if they aren't in the actual panel any more. |
Part of DH-18349. Will need a small update in dh.ui to enable support there which is what the ticket wants.
Does not change default behavior of
TabPanels, just adds an extra param to keep static panels mounted (in React, but not actually mounted in the DOM).There are unit tests, but can also test with local plugins from this PR deephaven/deephaven-plugins#1177