Skip to content

fix: global events broke on ios#1282

Open
danielbarion wants to merge 1 commit into
masterfrom
fix/issue-1281-global-events
Open

fix: global events broke on ios#1282
danielbarion wants to merge 1 commit into
masterfrom
fix/issue-1281-global-events

Conversation

@danielbarion

@danielbarion danielbarion commented Jun 12, 2026

Copy link
Copy Markdown
Member

fix #1281

Summary by CodeRabbit

  • New Features

    • Tooltip now opens on touch interaction when touch-based opening is enabled.
  • Bug Fixes

    • Fixed tooltip appearing after being closed by scroll or resize events.
  • Tests

    • Added test coverage for tooltip behavior during repeated touch interactions.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR fixes a bug where tooltips on iOS become permanently unresponsive after a scroll closes them. It adds delegated touchstart event handling to reopen tooltips on touch and clears pending show delays when scroll triggers a close, preventing stalled tooltip behavior.

Changes

iOS Tooltip Reopening

Layer / File(s) Summary
Touch open and delayed show cancellation
src/components/Tooltip/use-tooltip-events.tsx
Adds delegated touchstart listener to trigger tooltip show when hover/focus opening is enabled, and clears any pending show delay timer in the scroll/resize close handler to prevent stalled shows.
Test tooltip reopening sequence
src/test/tooltip-anchor-selection.spec.js
Validates the touch → scroll → touch sequence, confirming tooltip reopens correctly after a scroll closes it.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • gabrieljablonski

Poem

🐰 A touch upon the screen so fair,
No scroll shall leave the tooltip bare,
With timers cleared before they fire,
iOS users now can admire!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix: global events broke on ios' directly relates to and summarizes the main change—fixing global event handling that was broken on iOS platforms.
Linked Issues check ✅ Passed The changes fix the core iOS issue [#1281] by adding touchstart event handling and clearing pending show timers on scroll, addressing the bug where tooltips became permanently unresponsive after scroll.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the iOS global events bug—modifications to useTooltipEvents hook and a corresponding test case.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1281-global-events

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

Beta version released with the last commit 🚀

yarn add react-tooltip@6.0.7-beta.1282.rc.0

or

npm install react-tooltip@6.0.7-beta.1282.rc.0

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/Tooltip/use-tooltip-events.tsx (1)

360-364: ⚡ Quick win

Consider adding { passive: true } to the touchstart listener for better scroll performance.

Touch event listeners that don't call preventDefault should be marked passive to allow the browser to optimize scrolling, especially on mobile devices where this fix is needed.

⚡ Proposed performance improvement
 if (actualOpenEvents.mouseenter || actualOpenEvents.mouseover || actualOpenEvents.focus) {
-  addDelegatedListener('touchstart', (event) => {
+  addDelegatedListener('touchstart', (event) => {
     debouncedHandleShowTooltip(resolveAnchorElementRef.current(event.target))
-  })
+  }, { passive: true })
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Tooltip/use-tooltip-events.tsx` around lines 360 - 364, The
touchstart handler added in the conditional that checks actualOpenEvents (inside
use-tooltip-events) should be registered as a passive listener to improve scroll
performance: update the call to addDelegatedListener('touchstart', ...) to pass
{ passive: true } (or an options object your helper accepts) so the browser
knows preventDefault won't be called; keep the same callback that calls
debouncedHandleShowTooltip(resolveAnchorElementRef.current(event.target)) and
ensure addDelegatedListener supports an options parameter or overload it
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/test/tooltip-anchor-selection.spec.js`:
- Around line 80-81: The test fires touchStart but never advances fake timers or
asserts the tooltip reopened; update the test around the
fireEvent.touchStart(anchor) + await waitForTooltip('touch-scroll-test')
sequence to advance timers (e.g., jest.advanceTimersByTime or runAllTimers) by
at least the 50ms debounce so the touch handler runs, then assert the tooltip
element is present in the document (from waitForTooltip) and that it does not
have the 'closing' class; apply the same change to the similar block at lines
86-89 so both touch-scroll scenarios advance timers and verify reopen +
non-closing state.

---

Nitpick comments:
In `@src/components/Tooltip/use-tooltip-events.tsx`:
- Around line 360-364: The touchstart handler added in the conditional that
checks actualOpenEvents (inside use-tooltip-events) should be registered as a
passive listener to improve scroll performance: update the call to
addDelegatedListener('touchstart', ...) to pass { passive: true } (or an options
object your helper accepts) so the browser knows preventDefault won't be called;
keep the same callback that calls
debouncedHandleShowTooltip(resolveAnchorElementRef.current(event.target)) and
ensure addDelegatedListener supports an options parameter or overload it
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d55ce7a2-145f-444a-9130-9f889735182e

📥 Commits

Reviewing files that changed from the base of the PR and between 1099ad1 and e74d5a5.

📒 Files selected for processing (2)
  • src/components/Tooltip/use-tooltip-events.tsx
  • src/test/tooltip-anchor-selection.spec.js

Comment thread src/test/tooltip-anchor-selection.spec.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] globalCloseEvents.scroll permanently breaks tooltip on iOS

1 participant