Skip to content

Commit

Permalink
fix: la bruker interagere med åpent PopupTip
Browse files Browse the repository at this point in the history
  • Loading branch information
piofinn committed Nov 12, 2024
1 parent 9d74103 commit 1ff8ff7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/jokul/src/components/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions packages/jokul/src/components/tooltip/TooltipTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTooltipContext } from "./Tooltip.js";

export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
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([
Expand All @@ -14,10 +14,6 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
forwardedRef,
]);

const handleBlur = () => {
triggerOn === "click" && setOpen(false);
};

const filterMaterialSymbols = (
maybeText: string | null | undefined,
) => {
Expand All @@ -44,10 +40,6 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
"data-tooltip-shown": isOpen,
style: { ...children.props.style },
tabIndex: triggerOn === "click" ? 0 : undefined,
onBlur: () => {
children.props.onBlur && children.props.onBlur();
handleBlur();
},
}),
);
}
Expand All @@ -60,7 +52,6 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
// Sørg for at vi ikke sender inn skjemaer ved klikk på knappen
type: "button",
ref,
onBlur: handleBlur,
"aria-label": ariaLabel,
...props,
})}
Expand Down
4 changes: 2 additions & 2 deletions packages/tooltip-react/src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions packages/tooltip-react/src/TooltipTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTooltipContext } from "./Tooltip";

export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
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([
Expand All @@ -14,10 +14,6 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
forwardedRef,
]);

const handleBlur = () => {
triggerOn === "click" && setOpen(false);
};

const filterMaterialSymbols = (
maybeText: string | null | undefined,
) => {
Expand All @@ -44,10 +40,6 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
"data-tooltip-shown": isOpen,
style: { ...children.props.style },
tabIndex: triggerOn === "click" ? 0 : undefined,
onBlur: () => {
children.props.onBlur && children.props.onBlur();
handleBlur();
},
}),
);
}
Expand All @@ -60,7 +52,6 @@ export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement>>(
// Sørg for at vi ikke sender inn skjemaer ved klikk på knappen
type: "button",
ref,
onBlur: handleBlur,
"aria-label": ariaLabel,
...props,
})}
Expand Down

0 comments on commit 1ff8ff7

Please sign in to comment.