Skip to content

Commit 76acd49

Browse files
committed
fix: update interface of tooltip
1 parent 68fe7cc commit 76acd49

File tree

1 file changed

+8
-48
lines changed

1 file changed

+8
-48
lines changed

src/tooltip/interfaces.ts

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,67 +19,27 @@ export interface TooltipProps {
1919
/**
2020
* Unique identifier for the tooltip instance. Changing this value will cause the tooltip
2121
* to recalculate its position, similar to how React's key prop works.
22-
*
23-
* This is useful when the tooltip needs to track a different element or respond to
24-
* significant content changes.
25-
*
26-
* If not provided and content is a string or number, it will be auto-generated from content.
22+
* If not provided and content is a string or number, it will be used as key.
2723
* For complex content (elements, fragments), you should provide an explicit trackKey.
28-
*
29-
* @remarks
30-
* - The trackKey is also applied as the data-testid attribute for testing purposes.
31-
* - Update trackKey when tooltip content changes significantly to force position recalculation.
32-
* - For dynamic content, use a unique value based on your state: `trackKey={`tooltip-${id}`}`
33-
*
34-
* @example
35-
* // Auto-generated from simple content
36-
* <Tooltip content="Help text" />
37-
*
38-
* // Explicit trackKey for complex content
39-
* <Tooltip content={<div>Rich content</div>} trackKey="help-tooltip" />
40-
*
41-
* // Explicit trackKey for dynamic content
42-
* <Tooltip content={dynamicText} trackKey={`user-${userId}`} />
43-
*
44-
* // Force recalculation when state changes
45-
* <Tooltip content={message} trackKey={`status-${currentStatus}`} />
4624
*/
4725
trackKey?: string | number;
4826

4927
/**
5028
* Position of the tooltip relative to the tracked element.
5129
* @defaultValue 'top'
5230
*/
53-
position?: PopoverProps.Position;
54-
31+
position?: TooltipProps.Position;
5532
/**
5633
* Callback fired when the user presses the Escape key while the tooltip is visible.
57-
*
58-
* Note: Managing tooltip visibility based on hover/focus/blur events is the
59-
* responsibility of the parent component. The parent should control when to
60-
* render/unmount this Tooltip component.
61-
*
62-
* @example
63-
* const [showTooltip, setShowTooltip] = useState(false);
64-
*
65-
* <button
66-
* onMouseEnter={() => setShowTooltip(true)}
67-
* onMouseLeave={() => setShowTooltip(false)}
68-
* onFocus={() => setShowTooltip(true)}
69-
* onBlur={() => setShowTooltip(false)}
70-
* >
71-
* Hover me
72-
* </button>
73-
* {showTooltip && (
74-
* <Tooltip
75-
* content="Help text"
76-
* getTrack={() => buttonRef.current}
77-
* onEscape={() => setShowTooltip(false)}
78-
* />
79-
* )}
8034
*/
8135
onEscape?: NonCancelableEventHandler;
8236
}
37+
export namespace TooltipProps {
38+
/**
39+
* Position of the tooltip relative to the tracked element.
40+
*/
41+
export type Position = PopoverProps.Position;
42+
}
8343

8444
/**
8545
* Internal tooltip props - includes props not exposed in public API.

0 commit comments

Comments
 (0)