fix(tooltip): position could change from top to side

This commit is contained in:
Tom (plebeius.eth)
2024-07-03 15:27:13 +02:00
parent 387851d743
commit 7fce789096
+2 -8
View File
@@ -1,5 +1,5 @@
import { useState, ReactNode } from 'react';
import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal } from '@floating-ui/react';
import { useFloating, autoUpdate, offset, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal } from '@floating-ui/react';
import styles from './tooltip.module.css';
interface TooltipProps {
@@ -16,13 +16,7 @@ const Tooltip = ({ content, children, showTooltip = true }: TooltipProps) => {
onOpenChange: setIsOpen,
placement: 'top',
whileElementsMounted: autoUpdate,
middleware: [
offset(5),
flip({
fallbackAxisSideDirection: 'start',
}),
shift(),
],
middleware: [offset(5), shift()],
});
const hover = useHover(context, { move: false, delay: { open: 500, close: 0 } });