Skip to content

Commit 09b2e4d

Browse files
fix(tooltip): allow props to be passed to wrapper (#1036)
1 parent 4b42384 commit 09b2e4d

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/components/Tooltip/Tooltip.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ export default {
121121
options: [true, false],
122122
control: { type: 'inline-radio' },
123123
},
124+
wrapperProps: {
125+
control: { type: 'object' },
126+
},
124127
},
125128
} as ComponentMeta<typeof Tooltip>;
126129

src/components/Tooltip/Tooltip.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const Tooltip: FC<TooltipProps> = React.memo(
9595
width,
9696
wrapperClassNames,
9797
wrapperStyle,
98+
wrapperProps = {},
9899
...rest
99100
},
100101
ref: React.ForwardedRef<TooltipRef>
@@ -615,6 +616,7 @@ export const Tooltip: FC<TooltipProps> = React.memo(
615616
className={referenceWrapperClassNames}
616617
style={wrapperStyle}
617618
id={tooltipWrapperId?.current}
619+
{...wrapperProps}
618620
onClick={(
619621
event: React.MouseEvent<HTMLDivElement, MouseEvent>
620622
): void => {
@@ -670,6 +672,7 @@ export const Tooltip: FC<TooltipProps> = React.memo(
670672
id={tooltipWrapperId?.current}
671673
style={wrapperStyle}
672674
ref={reference}
675+
{...wrapperProps}
673676
{...(TRIGGER_TO_HANDLER_MAP_ON_LEAVE[trigger] && !gestureType
674677
? {
675678
[TRIGGER_TO_HANDLER_MAP_ON_LEAVE[trigger]]: toggle(

src/components/Tooltip/Tooltip.types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ export interface TooltipProps
242242
* The Wrapper style.
243243
*/
244244
wrapperStyle?: React.CSSProperties;
245+
246+
/**
247+
* The props of the Tooltip wrapper.
248+
* @default {}
249+
*/
250+
wrapperProps?: React.HTMLAttributes<HTMLDivElement>;
245251
}
246252

247253
export type TooltipRef = {

0 commit comments

Comments
 (0)