Skip to content

fix: update tooltip types to allow click events properly#1266

Merged
danielbarion merged 1 commit intomasterfrom
fix/Issue-1223-events
Apr 10, 2026
Merged

fix: update tooltip types to allow click events properly#1266
danielbarion merged 1 commit intomasterfrom
fix/Issue-1223-events

Conversation

@danielbarion
Copy link
Copy Markdown
Member

@danielbarion danielbarion commented Apr 9, 2026

Fixes #1223

Summary by CodeRabbit

  • Refactor
    • Streamlined internal type definitions in the Tooltip component for improved code maintainability and reduced redundancy. No functional changes or user-facing impact.

@danielbarion danielbarion self-assigned this Apr 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Beta version released with the last commit 🚀

yarn add react-tooltip@5.30.0-beta.1266.rc.0

or

npm install react-tooltip@5.30.0-beta.1266.rc.0

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

This pull request refactors tooltip event type definitions by consolidating click-related events into a shared AnchorClickEvents union type and restructuring AnchorOpenEvents and AnchorCloseEvents using the Partial<Record<...>> pattern, adding mousedown support to close events.

Changes

Cohort / File(s) Summary
Type Definition Refactoring
src/components/Tooltip/TooltipTypes.d.ts
Introduced internal AnchorClickEvents union type for shared click-related events (click | dblclick | mousedown | mouseup). Restructured AnchorOpenEvents and AnchorCloseEvents from explicit optional properties to Partial<Record<...>> pattern, enabling mousedown in close events and consolidating duplicate event definitions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • #1245: Modifies tooltip anchor event handling with changes to open/close event keys and mouse-related event support.
  • #1194: Updates AnchorOpenEvents and AnchorCloseEvents type declarations in the same file with event key expansions.

Suggested labels

Bug

Poem

🐰 Click and double-click aligned,
Mousedown joins the close-event line,
Types are trimmed with record neat,
Anchor events now complete!

🚥 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 title accurately reflects the main change: updating tooltip types to properly allow click events, which is the core refactoring visible in the changeset.
Linked Issues check ✅ Passed The PR successfully addresses issue #1223 by adding mousedown event support to closeEvents through the refactored AnchorClickEvents union and AnchorCloseEvents type.
Out of Scope Changes check ✅ Passed All changes are scoped to the tooltip types file and directly support the objective of enabling mousedown as a close trigger; no unrelated changes detected.
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-1223-events

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Tooltip/TooltipTypes.d.ts`:
- Around line 88-92: The type AnchorOpenEvents currently reuses
AnchorClickEvents which includes 'mouseup', but Tooltip.tsx's click-mode logic
only handles 'click', 'dblclick', and 'mousedown', so remove 'mouseup' from the
set exposed in AnchorOpenEvents: either (a) narrow AnchorClickEvents to only
'click' | 'dblclick' | 'mousedown' or (b) introduce a new type (e.g.,
AnchorClickEventsRuntime or AnchorClickOpenEvents) that omits 'mouseup' and use
that in AnchorOpenEvents; update any references to
AnchorClickEvents/AnchorOpenEvents accordingly so the public type aligns with
the runtime checks in Tooltip.tsx (click handling).
🪄 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: ecd8690a-ebdd-4ac8-95cf-c829a7a211bd

📥 Commits

Reviewing files that changed from the base of the PR and between 3346e9f and 1a04317.

📒 Files selected for processing (1)
  • src/components/Tooltip/TooltipTypes.d.ts

Comment on lines +88 to +92
type AnchorClickEvents = 'click' | 'dblclick' | 'mousedown' | 'mouseup'

export type AnchorOpenEvents = Partial<
Record<'mouseenter' | 'focus' | 'mouseover' | AnchorClickEvents, boolean>
>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

AnchorOpenEvents is now overly permissive and allows unsupported mouseup

On Line 88 and Line 90, sharing AnchorClickEvents makes openEvents.mouseup type-valid, but Tooltip.tsx click-mode logic (Line 104 in src/components/Tooltip/Tooltip.tsx) only checks click, dblclick, and mousedown. This exposes a config key that likely won’t behave as expected.

Suggested type split to keep API aligned with runtime behavior
-type AnchorClickEvents = 'click' | 'dblclick' | 'mousedown' | 'mouseup'
+type AnchorOpenClickEvents = 'click' | 'dblclick' | 'mousedown'
+type AnchorCloseClickEvents = AnchorOpenClickEvents | 'mouseup'

 export type AnchorOpenEvents = Partial<
-  Record<'mouseenter' | 'focus' | 'mouseover' | AnchorClickEvents, boolean>
+  Record<'mouseenter' | 'focus' | 'mouseover' | AnchorOpenClickEvents, boolean>
 >
 export type AnchorCloseEvents = Partial<
-  Record<'mouseleave' | 'blur' | 'mouseout' | AnchorClickEvents, boolean>
+  Record<'mouseleave' | 'blur' | 'mouseout' | AnchorCloseClickEvents, boolean>
 >
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Tooltip/TooltipTypes.d.ts` around lines 88 - 92, The type
AnchorOpenEvents currently reuses AnchorClickEvents which includes 'mouseup',
but Tooltip.tsx's click-mode logic only handles 'click', 'dblclick', and
'mousedown', so remove 'mouseup' from the set exposed in AnchorOpenEvents:
either (a) narrow AnchorClickEvents to only 'click' | 'dblclick' | 'mousedown'
or (b) introduce a new type (e.g., AnchorClickEventsRuntime or
AnchorClickOpenEvents) that omits 'mouseup' and use that in AnchorOpenEvents;
update any references to AnchorClickEvents/AnchorOpenEvents accordingly so the
public type aligns with the runtime checks in Tooltip.tsx (click handling).

@danielbarion danielbarion merged commit a1cd387 into master Apr 10, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT REQ] Add mousedown event to closeEvents property

1 participant