Skip to content

feat: Add keepMounted param to TabPanels for persisting panels when they are not active#2434

Merged
mattrunyon merged 2 commits intodeephaven:mainfrom
mattrunyon:mattrunyon_dh-18349
May 6, 2025
Merged

feat: Add keepMounted param to TabPanels for persisting panels when they are not active#2434
mattrunyon merged 2 commits intodeephaven:mainfrom
mattrunyon:mattrunyon_dh-18349

Conversation

@mattrunyon
Copy link
Copy Markdown
Collaborator

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

@mattrunyon mattrunyon requested review from a team and Copilot May 6, 2025 20:14
@mattrunyon mattrunyon self-assigned this May 6, 2025
@mattrunyon mattrunyon requested review from dgodinez-dh and removed request for a team May 6, 2025 20:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

codecov Bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 86.48649% with 5 lines in your changes missing coverage. Please review.

Project coverage is 47.10%. Comparing base (6d65594) to head (b0192bc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/components/src/spectrum/TabPanels.tsx 86.48% 5 Missing ⚠️
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              
Flag Coverage Δ
unit 47.10% <86.48%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dgodinez-dh
dgodinez-dh previously approved these changes May 6, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Comment thread packages/components/src/spectrum/TabPanels.tsx
@mattrunyon
Copy link
Copy Markdown
Collaborator Author

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.

@mattrunyon mattrunyon enabled auto-merge (squash) May 6, 2025 21:04
@mattrunyon mattrunyon merged commit 09077bf into deephaven:main May 6, 2025
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants