Skip to content

fix: Remove extra ref on Tooltip#3782

Merged
alanbsmith merged 2 commits intoWorkday:supportfrom
mannycarrera4:mc-remove-ref
Feb 19, 2026
Merged

fix: Remove extra ref on Tooltip#3782
alanbsmith merged 2 commits intoWorkday:supportfrom
mannycarrera4:mc-remove-ref

Conversation

@mannycarrera4
Copy link
Contributor

@mannycarrera4 mannycarrera4 commented Feb 19, 2026

Summary

Remove extra ref adding on Tooltip. This allows correct ref forwarding for Popups.

Release Category

Components

Release Note

This change added an extra ref that overrides the popupStack.ref which breaks consumers passing in their own ref. Removing this should fix the issue.


Checklist

For the Reviewer

  • PR title is short and descriptive
  • PR summary describes the change (Fixes/Resolves linked correctly)
  • PR Release Notes describes additional information useful to call out in a release message or removed if not applicable
  • Breaking Changes provides useful information to upgrade to this code or removed if not applicable

Where Should the Reviewer Start?

Areas for Feedback? (optional)

  • Code
  • Documentation
  • Testing
  • Codemods

Testing Manually

Screenshots or GIFs (if applicable)

Thank You Gif (optional)

@RayRedGoose RayRedGoose requested a review from Copilot February 19, 2026 22:39
Copy link
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 pull request attempts to fix ref forwarding issues in the Tooltip component by removing the ref: elementRef assignment from the cloned children element. The change aims to allow correct ref forwarding for Popups, but has unintended consequences.

Changes:

  • Removed ref: elementRef from the props spread when cloning children in the Tooltip component

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 143 to 146
...(/^(muted|describe)$/.test(type) && children.props['aria-label']
? {'aria-label': children.props['aria-label']}
: {}),
ref: elementRef,
})}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

Removing the ref: elementRef assignment breaks the focus-visible tracking functionality. The targetRef at line 116 is created using useLocalRef, but elementRef is no longer attached to any element after this removal. This means targetRef.current will always be null, causing the useEffect at lines 118-136 to never set up focus event listeners, and elementHasFocus will always remain false, breaking the focus-visible styling feature.

If the goal is to fix ref forwarding conflicts (as suggested by the PR description), the correct solution would be to use useForkRef to merge any existing ref from children with elementRef, rather than removing the ref entirely. For example:

const forkedRef = useForkRef(children.ref, elementRef);
// then use forkedRef in cloneElement

Alternatively, if the focus-visible feature is no longer needed, the entire useEffect, targetRef/elementRef logic, and elementHasFocus should be removed.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is already being done by targetProp so no need to add the extra ref here.

Comment on lines 143 to 146
...(/^(muted|describe)$/.test(type) && children.props['aria-label']
? {'aria-label': children.props['aria-label']}
: {}),
ref: elementRef,
})}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The useLocalRef hook is now unused since elementRef is no longer being attached to any element. The variables targetRef and elementRef from line 116 should be removed, along with the entire useEffect (lines 118-136) and the elementHasFocus state (line 115), since these features will no longer function without the ref being attached. The elementHasFocus prop at line 155 should also be removed.

Copilot uses AI. Check for mistakes.
@cypress
Copy link

cypress bot commented Feb 19, 2026

Workday/canvas-kit    Run #10372

Run Properties:  status check passed Passed #10372  •  git commit 9c4aa3303e ℹ️: Merge a8b2214f8b0b31d446ef7d5e7a191cb2697e5d01 into 9cda434c5b5bcc021d5c77883f3d...
Project Workday/canvas-kit
Branch Review mc-remove-ref
Run status status check passed Passed #10372
Run duration 02m 59s
Commit git commit 9c4aa3303e ℹ️: Merge a8b2214f8b0b31d446ef7d5e7a191cb2697e5d01 into 9cda434c5b5bcc021d5c77883f3d...
Committer Manuel Carrera
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 21
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 936
View all changes introduced in this branch ↗︎
UI Coverage  20.57%
  Untested elements 1438  
  Tested elements 370  
Accessibility  99.28%
  Failed rules  6 critical   5 serious   0 moderate   2 minor
  Failed elements 98  
@alanbsmith alanbsmith merged commit 6d69b01 into Workday:support Feb 19, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants