Skip to content

Commit 55af0b1

Browse files
committed
simplify tooltip trigger
1 parent 54ff9b2 commit 55af0b1

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

client/common/Tooltip.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, {
22
createContext,
33
forwardRef,
4-
isValidElement,
54
HTMLProps,
65
ReactNode,
76
useContext,
@@ -104,30 +103,17 @@ export function Tooltip({children, ...options}: { children: ReactNode } & Toolti
104103

105104
export const TooltipTrigger = forwardRef<
106105
HTMLElement,
107-
HTMLProps<HTMLElement> & {asChild?: boolean}
108-
>(({children, asChild = false, ...props}, forwardedRef) => {
106+
HTMLProps<HTMLElement>
107+
>(({children, ...props}, forwardedRef) => {
109108
const context = useTooltipContext();
110109
const childrenRef = (children as any).ref;
111110
const ref = useMergeRefs([context.refs.setReference, forwardedRef, childrenRef]);
112111

113-
// `asChild` allows the user to pass any element as the anchor
114-
if (asChild && isValidElement(children)) {
115-
return React.cloneElement(
116-
children,
117-
context.getReferenceProps({
118-
ref,
119-
...props,
120-
...children.props,
121-
'data-state': context.open ? 'open' : 'closed'
122-
})
123-
);
124-
}
125-
126-
return (
112+
return (
127113
<div
128114
ref={ref}
129115
// The user can style the trigger based on the state
130-
data-state={context.open ? "open" : "closed"}
116+
data-state={context.open ? 'open' : 'closed'}
131117
{...context.getReferenceProps(props)}
132118
>
133119
{children}

0 commit comments

Comments
 (0)