Skip to content

Commit a750794

Browse files
dylanjeffersclaude
andauthored
Fix Tooltip onClick handler invocation bug (#14075)
## Summary Fixed a bug in the Tooltip component where the onClick handler was being invoked immediately instead of being passed as a reference to the child element. ## Key Changes - Removed the function invocation operator `()` from `onClick()` to `onClick` in the Tooltip component - This ensures the onClick handler is properly retrieved as a function reference rather than being called during the assignment ## Implementation Details The bug was in the onClick handler extraction logic where `children.props?.onClick()` was immediately invoking the function and assigning its return value. The fix changes this to `children.props?.onClick`, which correctly retrieves the function reference so it can be called later with the proper event context via `originalOnClick(event)`. This prevents unintended function execution and ensures the original onClick handler is invoked at the appropriate time with the correct event object. https://claude.ai/code/session_019WWv3CGtetHF8EPZRaa5Tp Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2ec3349 commit a750794

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/harmony/src/components/tooltip/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export const Tooltip = ({
214214
if (isValidElement(children)) {
215215
const originalOnClick = (
216216
children as ReactElement<{ onClick?: any }>
217-
).props?.onClick()
217+
).props?.onClick
218218
if (typeof originalOnClick === 'function') {
219219
originalOnClick(event)
220220
}

0 commit comments

Comments
 (0)