Skip to content

fix(test): feature detection for IntersectionObserver #4378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mfranzke
Copy link
Collaborator

Proposed changes

Resolves #4370

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (fix on existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Further comments

@mfranzke mfranzke self-assigned this Jun 13, 2025
@mfranzke mfranzke requested a review from nmerget as a code owner June 13, 2025 16:24
@mfranzke mfranzke added the 🐛bug Something isn't working label Jun 13, 2025
@mfranzke mfranzke linked an issue Jun 13, 2025 that may be closed by this pull request
7 tasks
@mfranzke mfranzke added the 👩‍👧‍👦communityFeedback Feedback from community label Jun 13, 2025
@mfranzke mfranzke moved this to 👀 In review in UX Engineering Team Backlog Jun 13, 2025
@mfranzke mfranzke removed their assignment Jun 13, 2025
@mfranzke mfranzke changed the title fix: feature detection for IntersectionObserver fix(test): feature detection for IntersectionObserver Jun 13, 2025
@mfranzke mfranzke enabled auto-merge (squash) June 13, 2025 16:26
Copy link
Contributor

@mfranzke mfranzke requested a review from Copilot June 16, 2025 05:03
Copy link
Contributor

@Copilot 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 fixes feature detection for IntersectionObserver in several UI components to ensure that the observer is only instantiated in environments where it is available.

  • Added runtime checks for IntersectionObserver in tooltip, popover, and custom-select components.
  • Ensured that observer initialization is conditioned on window availability and presence of IntersectionObserver.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/components/src/components/tooltip/tooltip.lite.tsx Added feature detection block for IntersectionObserver.
packages/components/src/components/popover/popover.lite.tsx Added feature detection block for IntersectionObserver.
packages/components/src/components/custom-select/custom-select.lite.tsx Added feature detection block for IntersectionObserver.
Comments suppressed due to low confidence (2)

packages/components/src/components/tooltip/tooltip.lite.tsx:120

  • Consider adding cleanup logic to disconnect the observer when the component unmounts to prevent potential memory leaks if this is not already handled elsewhere.
if (typeof window !== 'undefined' && 'IntersectionObserver' in window) {

packages/components/src/components/popover/popover.lite.tsx:133

  • Ensure that the observer is properly disconnected during cleanup to avoid any lingering observers after the component unmounts.
if (typeof window !== 'undefined' && 'IntersectionObserver' in window) {

@mfranzke mfranzke requested a review from michaelmkraus June 16, 2025 07:34
@mfranzke mfranzke disabled auto-merge June 16, 2025 08:37
@mfranzke mfranzke merged commit 23ae259 into main Jun 16, 2025
74 checks passed
@mfranzke mfranzke deleted the 4370-tooltip-can-not-be-rendered-in-test-with-react-testing-library branch June 16, 2025 08:37
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in UX Engineering Team Backlog Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working 👩‍👧‍👦communityFeedback Feedback from community
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Tooltip: Can not be rendered in Test with react-testing-library
1 participant