diff --git a/packages/jokul/src/components/tooltip/Tooltip.tsx b/packages/jokul/src/components/tooltip/Tooltip.tsx index db69beee5e4..f2e81e27548 100644 --- a/packages/jokul/src/components/tooltip/Tooltip.tsx +++ b/packages/jokul/src/components/tooltip/Tooltip.tsx @@ -84,9 +84,9 @@ const useTooltip = ({ }); const role = useRole(data.context, { role: "tooltip" }); - const dismiss = useDismiss(data.context, { referencePress: false }); + const dismiss = useDismiss(data.context); const click = useClick(data.context, { - enabled: triggerOn === "click" && !isOpen, + enabled: triggerOn === "click", }); const hover = useHover(data.context, { enabled: triggerOn === "hover", diff --git a/packages/jokul/src/components/tooltip/TooltipTrigger.tsx b/packages/jokul/src/components/tooltip/TooltipTrigger.tsx index f3ce43d3e57..48fe398b8da 100644 --- a/packages/jokul/src/components/tooltip/TooltipTrigger.tsx +++ b/packages/jokul/src/components/tooltip/TooltipTrigger.tsx @@ -5,7 +5,7 @@ import { useTooltipContext } from "./Tooltip.js"; export const TooltipTrigger = forwardRef>( function TooltipTrigger({ children, className, ...props }, forwardedRef) { - const { isOpen, setOpen, getReferenceProps, refs, triggerOn } = + const { isOpen, getReferenceProps, refs, triggerOn } = useTooltipContext(); const childrenRef = (children as any).ref; const ref = useMergeRefs([ @@ -14,10 +14,6 @@ export const TooltipTrigger = forwardRef>( forwardedRef, ]); - const handleBlur = () => { - triggerOn === "click" && setOpen(false); - }; - const filterMaterialSymbols = ( maybeText: string | null | undefined, ) => { @@ -44,10 +40,6 @@ export const TooltipTrigger = forwardRef>( "data-tooltip-shown": isOpen, style: { ...children.props.style }, tabIndex: triggerOn === "click" ? 0 : undefined, - onBlur: () => { - children.props.onBlur && children.props.onBlur(); - handleBlur(); - }, }), ); } @@ -60,7 +52,6 @@ export const TooltipTrigger = forwardRef>( // Sørg for at vi ikke sender inn skjemaer ved klikk på knappen type: "button", ref, - onBlur: handleBlur, "aria-label": ariaLabel, ...props, })} diff --git a/packages/tooltip-react/src/Tooltip.tsx b/packages/tooltip-react/src/Tooltip.tsx index cc0c1ff6eab..b2281491d01 100644 --- a/packages/tooltip-react/src/Tooltip.tsx +++ b/packages/tooltip-react/src/Tooltip.tsx @@ -71,9 +71,9 @@ export const useTooltip = ({ }); const role = useRole(data.context, { role: "tooltip" }); - const dismiss = useDismiss(data.context, { referencePress: false }); + const dismiss = useDismiss(data.context); const click = useClick(data.context, { - enabled: triggerOn === "click" && !isOpen, + enabled: triggerOn === "click", }); const hover = useHover(data.context, { enabled: triggerOn === "hover", diff --git a/packages/tooltip-react/src/TooltipTrigger.tsx b/packages/tooltip-react/src/TooltipTrigger.tsx index 0c2bca8c8ec..a14820b720d 100644 --- a/packages/tooltip-react/src/TooltipTrigger.tsx +++ b/packages/tooltip-react/src/TooltipTrigger.tsx @@ -5,7 +5,7 @@ import { useTooltipContext } from "./Tooltip"; export const TooltipTrigger = forwardRef>( function TooltipTrigger({ children, className, ...props }, forwardedRef) { - const { isOpen, setOpen, getReferenceProps, refs, triggerOn } = + const { isOpen, getReferenceProps, refs, triggerOn } = useTooltipContext(); const childrenRef = (children as any).ref; const ref = useMergeRefs([ @@ -14,10 +14,6 @@ export const TooltipTrigger = forwardRef>( forwardedRef, ]); - const handleBlur = () => { - triggerOn === "click" && setOpen(false); - }; - const filterMaterialSymbols = ( maybeText: string | null | undefined, ) => { @@ -44,10 +40,6 @@ export const TooltipTrigger = forwardRef>( "data-tooltip-shown": isOpen, style: { ...children.props.style }, tabIndex: triggerOn === "click" ? 0 : undefined, - onBlur: () => { - children.props.onBlur && children.props.onBlur(); - handleBlur(); - }, }), ); } @@ -60,7 +52,6 @@ export const TooltipTrigger = forwardRef>( // Sørg for at vi ikke sender inn skjemaer ved klikk på knappen type: "button", ref, - onBlur: handleBlur, "aria-label": ariaLabel, ...props, })}