fix: update tooltip types to allow click events properly#1266
fix: update tooltip types to allow click events properly#1266danielbarion merged 1 commit intomasterfrom
Conversation
|
Beta version released with the last commit 🚀 or |
📝 WalkthroughWalkthroughThis pull request refactors tooltip event type definitions by consolidating click-related events into a shared Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/components/Tooltip/TooltipTypes.d.ts
| type AnchorClickEvents = 'click' | 'dblclick' | 'mousedown' | 'mouseup' | ||
|
|
||
| export type AnchorOpenEvents = Partial< | ||
| Record<'mouseenter' | 'focus' | 'mouseover' | AnchorClickEvents, boolean> | ||
| > |
There was a problem hiding this comment.
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).
Fixes #1223
Summary by CodeRabbit