From f7c8e04ce64c8d1dcd570f9e5152cf8e200f53bb Mon Sep 17 00:00:00 2001 From: Tamajit-005 Date: Sat, 6 Jun 2026 23:54:31 +0530 Subject: [PATCH 1/2] feat(Tooltip): add boundary prop to hide tooltip when it escapes an element Adds an optional 'boundary' prop to useTooltip/Tooltip that activates FloatingUI's 'hide' middleware with strategy='escaped'. When the tooltip would overflow the boundary, it gets the 'invisible' class (clip-path: inset(50%)) so it remains in the DOM for screen readers but is visually hidden. The boundary is also passed to the 'flip' middleware so the initial placement is more likely to stay inside it. This lets consumers like Element Web keep the 'Expand map' tooltip on location messages from overlapping the message composer at the bottom of the timeline. --- src/components/Tooltip/Tooltip.tsx | 5 ++++- src/components/Tooltip/useTooltip.ts | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx index e7b502812..09805ea8f 100644 --- a/src/components/Tooltip/Tooltip.tsx +++ b/src/components/Tooltip/Tooltip.tsx @@ -127,6 +127,9 @@ function TooltipContent({ // Label tooltips are kept in the DOM even when not visually open if (!open && purpose !== "label") return null; + // Hide the tooltip if it has escaped its boundary (when `boundary` prop is set) + const escaped = floatingContext.middlewareData?.hide?.escaped ?? false; + return (