Optimizes MdTooltip by unmounting when hidden by default - #565
Open
Helge Johnsen (hj-inmeta) wants to merge 4 commits into
Open
Helge Johnsen (hj-inmeta) wants to merge 4 commits into
Helge Johnsen (hj-inmeta) wants to merge 4 commits into
Conversation
The `unmountOnHide` prop now defaults to `true` for the `MdTooltip` component. This change significantly reduces initial DOM overhead and improves rendering performance by ensuring tooltips are only mounted to the DOM when they are visible.
Updates the `MdTag` test for `tooltipOnly` mode to accurately reflect its rendering behavior. The previous assertion incorrectly expected the label text to be present in the document, even when visually hidden. This correction verifies that when `tooltipOnly` is active, the label content is exclusively managed by the `MdTooltip` component and is not directly rendered in the DOM, aligning with the default `unmountOnHide` behavior of `MdTooltip`. This ensures the test suite correctly validates the component's state following recent tooltip performance optimizations.
Copilot started reviewing on behalf of
Helge Johnsen (hj-inmeta)
September 14, 2026 09:40
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Address the tooltip-only accessibility issue and add interaction coverage for the new default behavior.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
MdTooltip now unmounts hidden content by default to reduce DOM overhead while preserving an opt-out.
Changes:
- Defaults
unmountOnHidetotrue. - Updates tooltip and tag tests.
- Preserves explicit persistent mounting.
File summaries
| File | Description |
|---|---|
packages/react/src/tooltip/tests/MdTooltip.test.tsx |
Tests tooltip mounting behavior. |
packages/react/src/tooltip/MdTooltip.tsx |
Changes the default mounting behavior and documentation. |
packages/react/src/tag/tests/MdTag.test.tsx |
Updates tooltip-only tag expectations. |
Review details
Suppressed comments (1)
packages/react/src/tooltip/MdTooltip.tsx:32
- With this default,
MdTag'stooltipOnlybranch (which wraps a bare SVG and supplies noaria-label) has no accessible name while idle: the tooltip text is now unmounted, so Ariakit cannot expose it through itsaria-describedbyrelationship until the tooltip opens. Keep that consumer's content mounted or provide an explicit accessible label before applying the new default.
unmountOnHide = true,
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+17
to
+21
| it('does not mount hidden tooltips for large collections', () => { | ||
| const { baseElement } = render( | ||
| <> | ||
| {Array.from({ length: 100 }, (_, index) => { | ||
| return ( |
| /** | ||
| * When `true`, the tooltip will be unmounted when it is hidden. This can be useful for performance reasons, but it may cause issues with animations or transitions. | ||
| * @default false | ||
| * @default true |
Denis Pokotylyuk (podeig)
approved these changes
Sep 23, 2026
Denis Pokotylyuk (podeig)
left a comment
There was a problem hiding this comment.
Hei Helge, Den ser fint ut for meg. Bare se på kommentarene fra Copilot :) Bra jobba, tusen takk for fiksen! 👍
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
The
unmountOnHideprop now defaults totruefor theMdTooltipcomponent. This change significantly reduces initial DOM overhead and improves rendering performance by ensuring tooltips are only mounted to the DOM when they are visible.Checklist before requesting a review
major,minororpatch)stories-folder?packages/react/index.tsx?packages/css/index.css?