Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 17, 2025

The DBTooltip component was failing with a TypeError when the tooltip element was removed from the DOM during the 1ms delay used for positioning. This race condition occurred in automated tests and fast user interactions.

Problem

When a tooltip trigger is hovered, handleAutoPlacement is called with a 1ms delay to work around Angular-specific timing issues. However, if the component gets unmounted before this delay completes, the _ref becomes null, causing handleFixedPopover to fail:

TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

This typically happened in test scenarios where components were rapidly mounted and unmounted, but could also occur in real applications during fast user interactions.

Solution

Added a null check for _ref inside the delayed callback to prevent calling handleFixedPopover with a null reference:

utilsDelay(() => {
    if (_ref) {  // Added null check
        handleFixedPopover(_ref, parent, placement ?? 'bottom');
    }
}, 1);

Impact

  • Minimal change: Only 2 lines added, no existing functionality modified
  • Safe: Maintains all existing tooltip behavior while preventing crashes
  • Complete coverage: Fix automatically applied to all framework outputs (React, Vue, Angular, Stencil)
  • No performance impact: The null check is negligible overhead

The fix has been verified with manual testing showing tooltips continue to work correctly, and all existing tests pass.

Tooltip demo showing working functionality

Fixes #4400.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2025

⚠️ No Changeset found

Latest commit: f3c595a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI changed the title [WIP] DBTooltip - local test failing after update to version > 2.1.2 fix: DBTooltip race condition when component unmounts during delayed positioning Sep 17, 2025
Copilot AI requested a review from mfranzke September 17, 2025 08:10
@mfranzke mfranzke moved this to 🏗 In development in UX Engineering Team Backlog Sep 17, 2025
@mfranzke mfranzke marked this pull request as ready for review September 17, 2025 08:49
@mfranzke mfranzke enabled auto-merge (squash) September 17, 2025 08:49
@mfranzke mfranzke disabled auto-merge September 17, 2025 08:53
@nmerget nmerget enabled auto-merge (squash) September 22, 2025 08:37
@nmerget nmerget moved this from 🏗 In development to 👀 In review in UX Engineering Team Backlog Sep 22, 2025
@nmerget nmerget self-assigned this Sep 23, 2025
@mfranzke mfranzke requested review from nmerget and removed request for mfranzke, michaelmkraus and sarahbrng September 24, 2025 15:41
@nmerget nmerget merged commit 80ec773 into main Sep 24, 2025
55 checks passed
@nmerget nmerget deleted the copilot/fix-4400 branch September 24, 2025 15:59
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in UX Engineering Team Backlog Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

DBTooltip - local test failing after update to version > 2.1.2

3 participants