diff --git a/packages/richtext-lexical/src/field/Field.tsx b/packages/richtext-lexical/src/field/Field.tsx index 284ed3466..73bf0e316 100644 --- a/packages/richtext-lexical/src/field/Field.tsx +++ b/packages/richtext-lexical/src/field/Field.tsx @@ -84,14 +84,14 @@ const _RichText: React.FC< width, }} > +
- {}}> +
- = (props) => { @@ -21,6 +25,7 @@ export const Tooltip: React.FC = (props) => { className, delay = 350, show: showFromProps = true, + staticPositioning = false, } = props const [show, setShow] = React.useState(showFromProps) @@ -28,11 +33,14 @@ export const Tooltip: React.FC = (props) => { const getTitleAttribute = (content) => (typeof content === 'string' ? content : '') - const [ref, intersectionEntry] = useIntersect({ - root: boundingRef?.current || null, - rootMargin: '-145px 0px 0px 100px', - threshold: 0, - }) + const [ref, intersectionEntry] = useIntersect( + { + root: boundingRef?.current || null, + rootMargin: '-145px 0px 0px 100px', + threshold: 0, + }, + staticPositioning, + ) useEffect(() => { let timerId: NodeJS.Timeout @@ -52,22 +60,25 @@ export const Tooltip: React.FC = (props) => { }, [showFromProps, delay]) useEffect(() => { + if (staticPositioning) return setPosition(intersectionEntry?.isIntersecting ? 'top' : 'bottom') - }, [intersectionEntry]) + }, [intersectionEntry, staticPositioning]) + // The first aside is always on top. The purpose of that is that it can reliably be used for the interaction observer (as it's not moving around), to calculate the position of the actual tooltip. return ( - - + {!staticPositioning && ( + + )}