[$175] Tooltip incorrectly overlaps the fixed filter toolbar
Actual behavior
The tooltip renders above the fixed filter toolbar, overlapping it.
Expected behavior
The tooltip should be tucked underneath the fixed filter toolbar.
Video
https://github.com/user-attachments/assets/ab5df86c-e9f9-4cfd-ad1c-f07bd1936488
cc @Expensify/design
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022123174109234820079
- Upwork Job ID: 2123174109234820079
- Last Price Increase: 2026-11-18
Issue Owner
Current Issue Owner: @Gonals
Proposal
Please re-state the problem that we are trying to solve in this issue.
When scrolling a page with a fixed header and filter toolbar (such as InsightsDashboard or SearchPageWide / SearchPageNarrow in chart or list view), tooltips — specifically ChartTooltip (when a bar/line/pie data point is hovered or touch-pinned while scrolling) and portaled BaseEducationalTooltip / BaseGenericTooltip — render on top of the fixed filter toolbar instead of tucking underneath (or hiding behind) the fixed header/filter toolbar.
What is the root cause of that problem?
There are two complementary causes in the tooltip rendering and positioning pipeline:
-
Portaled
zIndexstacking context & unclamped top boundary inChartTooltip(src/components/Charts/components/ChartTooltip.tsx&src/components/Charts/components/ChartTooltipPortal/index.tsx):ChartTooltipPortalportals the tooltip directly ontodocument.bodyon Web (ReactDOM.createPortal(children, body)) and onto the root<Portal>host on Native (src/components/Charts/components/ChartTooltipPortal/index.native.tsx), applyingstyles.chartTooltipLayer(zIndex: variables.tooltipZIndex=10050insrc/styles/index.ts).- Meanwhile, the fixed page header (
TopBar) and fixed filter toolbar (InsightsPageControlsinsrc/pages/Insights/InsightsDashboard.tsx:359-396,SearchActionsBarWideinsrc/components/Search/SearchPageHeader/SearchActionsBarWide.tsx:24withzIndex: 10, andSearchPageNarrowheader container withzIndex: 10/searchTopBarZIndex: 9) live inside the screen subtree at a much lower stacking context. - As the user scrolls the
ScrollView(InsightsDashboardContentorSearch),ChartTooltipAnchor(BoundsObserveron web) updatesorigin(originY), andtooltipStyleinsrc/components/Charts/components/ChartTooltip.tsx:161-177clampstopagainstconst minTop = safeAreaTop;(which is0on web/desktop and only the status bar inset on native) and flips the tooltip below the point viaPopoverWithMeasuredContentUtils.computeVerticalShift(topAbove - minTop, ...)only when it reachessafeAreaTop, not when it reaches the bottom of the fixed header + filter toolbar. Even worse, when a touch-pinned or hovered chart point scrolls up under the fixed filter toolbar, the portaled tooltip stays visible atzIndex: 10050right on top of the fixed filter toolbar.
-
Fixed filter toolbar height is not accounted for in
BaseEducationalTooltip(src/components/Tooltip/EducationalTooltip/BaseEducationalTooltip.tsx:85) and scroll dismissal:- In
BaseEducationalTooltip.tsx:85,availableHeightForTopis calculated asconst availableHeightForTop = top - (contentHeaderHeight - offset);, which only subtractscontentHeaderHeight(TopBarheight:72pxwide /64pxnarrow) and ignores the fixed filter/tab toolbar rendered directly beneathTopBarwhen!shouldScrollMainHeader.
- In
What changes do you think we should make in order to solve the problem?
Depending on whether the desired behavior for the tooltip is to tuck underneath the fixed header/filter toolbar (via stacking context / clipping) or to respect the fixed toolbar boundary when scrolling:
- Render
ChartTooltipwithin the scrollable/content stacking context (below the fixed header & filter toolbar) instead of portaling todocument.bodyabovezIndex: 10050, or lower its stacking layer relative to the fixed header/filter bar:- In
src/pages/Insights/InsightsDashboard.tsx(lines 359–401) andsrc/pages/Search/SearchPageWide.tsx/SearchPageNarrow/index.tsx, the fixedheader(TopBar+InsightsPageControls/SearchActionsBarWide) sits above the<View style={styles.flex1}>content area. - If the tooltip should visually tuck underneath the fixed filter toolbar as the chart scrolls up:
- Provide a scoped portal host (e.g. a
<PortalHost name="chartTooltip">/ content-level container ref inside the page content<View style={styles.flex1}>below the fixed header/filter toolbar, or keepoverflow: 'hidden'on the scroll viewport below the fixed header) rather than portaling todocument.bodyatzIndex: 10050, or ensure the fixed header + filter toolbar container establishes a stacking context above the chart content while the tooltip is portaled into the content layer below the fixed toolbar.
- Provide a scoped portal host (e.g. a
- Alternatively, if
ChartTooltipPortalremains ondocument.body/ rootPortal(so it is never clipped horizontally by card bounds), we can track the bottom boundary of the fixed header/toolbar (or dismiss/clip the tooltip on scroll):- In
src/components/Charts/components/ChartTooltip.tsx, listen toCONST.EVENTS.SCROLLING(emitted bytriggerScrollEventinInsightsDashboard.tsx:232andSearchPageNarrow/index.tsx:166, and wireuseScrollEventEmitterinSearch/index.tsx:1586forchartScrollViewRef) to either dismiss a touch-pinned tooltip on scroll or clamp/hideisTooltipShownwhen the anchor point (originY + y) scrolls above the fixed header + filter toolbar bottom edge (headerBottomY).
- In
- In
- For
BaseEducationalTooltip(src/components/Tooltip/EducationalTooltip/BaseEducationalTooltip.tsx):- Allow passing an additional top inset / fixed toolbar offset (or measuring the fixed header + filter bar container height) into
availableHeightForTop(top - (contentHeaderHeight + fixedToolbarHeight - offset)) so tooltips withshouldHideOnScrollhide as soon as their target moves under the fixed filter toolbar rather than waiting until it reachesTopBar.
- Allow passing an additional top inset / fixed toolbar offset (or measuring the fixed header + filter bar container height) into
What alternative solutions did you explore? (Optional)
- Raising the fixed filter toolbar's
zIndexabovevariables.tooltipZIndex(10050): Not recommended becausePopover(popoverZIndex: 10000) andModal(modalBaseZIndex: 9999) rely on the global z-index hierarchy insrc/styles/variables.ts, so elevating the filter bar above10050would cause the filter bar to overlap open modals and popovers. Scoping the tooltip layer beneath the fixed header/filter bar (or clipping/hiding at the toolbar's bottom edge) cleanly preserves modal and popover layering across all platforms.
@dubielzyk-expensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (External)
Job added to Upwork: https://www.upwork.com/jobs/~022123174109234820079
Not overdue. Waiting for proposals now
Proposal
What is the root cause of that problem?
In src/pages/Insights/InsightsDashboard.tsx (lines 545–581), the fixed header (TopBar + InsightsPageControls filter toolbar) renders above the scrollable content container (<View style={styles.flex1}>). While the chart cards scroll cleanly underneath the fixed filter toolbar, the chart tooltip (src/components/Charts/components/ChartTooltip.tsx) escapes that clipping boundary for three reasons:
- Root-level portaling above the fixed toolbar:
ChartTooltipPortalmounts the tooltip ondocument.bodyon web (src/components/Charts/components/ChartTooltipPortal/index.tsx) and on the root@gorhom/portalhost on native (index.native.tsx), placing it atzIndex: variables.tooltipZIndexabove the fixedheader. - Fixed viewport positioning on web:
styles.chartTooltipLayerspreadstooltipPlatformStyle, which isposition: 'fixed'on web (src/styles/utils/generators/TooltipStyleUtils/tooltipPlatformStyles/index.ts). Afixedelement ignores ancestoroverflow: hiddenclipping and always paints in viewport coordinates. - Window-based top clamping:
ChartTooltip.tsx(lines 164–174) computesoriginin window coordinates and clampstopagainstminTop = safeAreaTop(0on web/desktop), unaware of the fixed filter toolbar's bottom edge. As the hovered point approaches the toolbar during scroll, the tooltip remains positioned above the point and paints directly over theDate / Compare / Workspace / Exportcontrols instead of tucking underneath them.
What changes do you think we should make in order to solve the problem?
Scope the chart tooltip portal inside the scrollable dashboard viewport below the fixed filter toolbar so the tooltip tucks cleanly underneath the toolbar on both web and native without clipping against individual chart cards:
- Add an optional
ChartTooltipPortalContext(host ref on web, named@gorhom/portalPortalHoston native):- Provide a scoped host inside the content container
<View style={[styles.flex1, styles.overflowHidden]}>insrc/pages/Insights/InsightsDashboard.tsx(below{!shouldScrollMainHeader && header}), so its top edge aligns exactly with the bottom edge of the fixed filter toolbar. - Keep the existing root
document.body/ root<Portal>behavior as the default fallback whenever no scoped host is provided, so charts outsideInsightsDashboardare unaffected.
- Provide a scoped host inside the content container
- Switch scoped tooltips to host-relative
position: 'absolute'coordinates:- Web: In
ChartTooltipPortal/index.tsx, portal into the scoped host DOM node when present, and useposition: 'absolute'instead ofposition: 'fixed'so the host'soverflow: hiddennaturally clips the tooltip as it slides underneath the fixed filter toolbar. InChartTooltipAnchor/index.tsx, subtract the host element'sgetBoundingClientRect()(x, y)from the anchor bounds sooriginis relative to the scoped host (mirroring howChartTooltipAnchor/index.native.tsxalready computesx - hostX, y - hostYagainsthostOriginRef). - Native: Render a named
<PortalHost>inside<View style={[styles.flex1, styles.overflowHidden]}>and passhostNameto<Portal>inChartTooltipPortal/index.native.tsx;ChartTooltipAnchor/index.native.tsxalready measures relative to the portal host viahostOriginRef.
- Web: In
- Allow the tooltip to slide naturally underneath the top edge when scoped:
- In
ChartTooltip.tsx(tooltipStyle), when rendered inside a scoped clipping host, position vertically relative to the host without forcingMath.max(minTop, ...)or flipping away from the top edge before the anchor scrolls behind the toolbar — so the tooltip tucks smoothly underneath the fixed filter toolbar exactly like the chart card itself, while keeping horizontal clamping within the viewport. - Ensure
pointerEventsdoes not intercept clicks on the fixed filter toolbar above the clipping boundary.
- In
What alternative solutions did you explore? (Optional)
- Raising the filter toolbar
zIndexabovevariables.tooltipZIndex(10050): Rejected because globalModal(9999) andPopover(10000) layers sit below10050, so raising the toolbar above10050would cause it to overlap modals and dropdown popovers. - Dismissing the tooltip immediately on any scroll event: Rejected because the expected behavior is for the tooltip to remain visible and tuck smoothly underneath the fixed filter toolbar as the chart scrolls, rather than abruptly disappearing on minor scroll adjustments.
Not overdue. @rojiphil do we need more proposals here?
@danlopes18-ctrl Your fix is in the right direction i.e portal the chart tooltip into the content area under the fixed header, with overflow: hidden and host-relative position: absolute, so it clips under the toolbar. Keep the body or root portal as the fallback for charts that are not under a fixed toolbar. Do not raise the toolbar zIndex, and do not dismiss the tooltip on scroll.
Can you please share a test branch with this implementation so that I can conclude the review?
@rojiphil I took a different route to the same result, and I've shared a test branch and before/after videos below. Your constraints are all met: the toolbar's zIndex stays as it is, the tooltip isn't dismissed on scroll, and charts that aren't under a fixed toolbar keep the root portal. Updated: it now also covers the Spend search chart view, wide and narrow, as you asked in your later review.
How this differs from the dashboard portal proposal: that proposal moves the tooltip into a portal host inside the content area and converts ChartTooltipAnchor on web to host-relative position: absolute coordinates. This one leaves the tooltip on document.body, in the window coordinates it already uses, and clips it at the toolbar's measured bottom edge with clip-path. Positioning code stays as it is, nothing changes coordinate systems, and the change is smaller (about 90 lines).
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Insights, when you scroll with a chart tooltip showing, the tooltip covers the fixed filter toolbar (Date / Compare / Group currency / Export). It should slide underneath the toolbar like the chart does.
What is the root cause of that problem?
The toolbar is rendered above the dashboard's scrolling content in InsightsDashboard. On web, ChartTooltipPortal mounts the tooltip on document.body with position: fixed and zIndex: variables.tooltipZIndex, so nothing in the content area clips it. ChartTooltip only keeps the tooltip inside the window's safe area (minTop = safeAreaTop, 0 on web). It doesn't know where the toolbar ends, so it paints over the toolbar until the tooltip reaches the top of the window.
What changes do you think we should make in order to solve the problem?
- Add a
ChartTooltipClipBoundaryaround the Insights content area, below the fixed top bar and filter controls. On web it usesBoundsObserverto measure the top edge of the content area and passes that edge (clipTop) down through a smallChartTooltipClipTopContext. The value comes from layout, so it updates when the filter row wraps. On native it is a plainView. - In
ChartTooltipPortal(web), keep mounting ondocument.body. WhenclipTopis set, wrap the tooltip in a fixed full-window layer withclip-path: inset(<clipTop>px 0 0)andpointer-events: none. Whatever is above the edge is hidden and can't be clicked, so toolbar clicks still reach the toolbar, and a pressable tooltip keeps its ownpointerEvents: 'auto'. - Spend search charts (wide and narrow): wrap the chart scroll view in
Searchwith the same boundary.- Wide: the filter bar sits above the scroll view, so the clip edge is the scroll view's top.
- Narrow: the filter header floats over the chart's top padding and slides away as you scroll (
topBarOffsetinSearchPageNarrow). The boundary takes atopInset(the existinggetSearchNarrowHeaderHeight(hasFilterBars)) plus the header's current shift, whichSearchPageNarrowpasses down asheaderOffset. So the clip edge is always the header's current bottom: 228px with the header showing and 64px once it has slid away, where a fixed edge would hide tooltips in the space the header left. Only the boundary and its tooltips re-render as the header slides, not the Search page.
- In
ChartTooltip, whileclipTopis set, don't flip or clamp the tooltip at the top of the window. Flipping there would pull it back out from behind the toolbar. It just follows its point and slides under the toolbar.
Charts without a fixed toolbar get no clipTop and keep today's behavior exactly.
What alternative solutions did you explore? (Optional)
- Portal inside the content area with
overflow: hidden(the other proposal). This clips the top correctly too, but it converts the web anchor to host-relative coordinates and puts the tooltip under a clipping ancestor. That ancestor clips the tooltip's left and right sides as well, for example a tooltip on the first or last point near the edge of a narrow Spend chart, which is the reason the tooltip was moved todocument.bodyin the first place.clip-pathonly cuts the top edge. - Raising the toolbar's
zIndexor dismissing the tooltip on scroll. Rejected, for the reasons in your review.
One trade-off for design: if you hover a point sitting just under the toolbar without scrolling, part of its tooltip starts out under the toolbar. I tried flipping it below the point in that case, but then the tooltip jumps below its point while you scroll instead of tucking under, so I kept the tuck-under behavior the issue asks for. It's a one-line change if design prefers the flip.
Test branch
https://github.com/MannA-001/App/tree/test/106940-tooltip-toolbar (rebuilt on the latest main, now including the Spend chart view)
Checks on the branch: typecheck passes, lint adds no new errors, every changed component compiles with the React Compiler (Search/index.tsx already fails on main with the same 9 findings, unchanged), the 8 new tests pass, and the 93 existing chart, Search and Insights tests still pass.
Insights (desktop web 1440×900, local fixture with a signed-in workspace and simulated chart data):
- The tooltip slides under the toolbar and comes back out when you scroll back up.
- While it overlaps the toolbar, clicks on the toolbar controls still reach them (hit-tested on Export).
- When the window narrows and the filter row wraps, the cutoff moves with it (from 132px to 168px).
Before (main: the tooltip covers Compare / Group currency)
https://github.com/user-attachments/assets/77c55f7e-676e-4fdc-9c39-4f9893b6e9f6
After (test branch: the tooltip tucks under the toolbar)
https://github.com/user-attachments/assets/029a6f99-aaf9-41bd-8bb5-d2522765871f
Spend, wide (local fixture with 12 months of expenses in a bar chart: hover November, then scroll the chart up)
Before (main): the tooltip paints over Filters / Display
https://github.com/user-attachments/assets/7cde38b8-6926-430f-b243-9717656b35fd
After: the tooltip slides under the filter bar (clip edge 134px)
https://github.com/user-attachments/assets/923ce2aa-403f-458c-abf8-836641f0d852
Spend, narrow (390×520 touch: scroll down so the header slides away, scroll up a little so it slides back over the chart, then tap November)
Before (main): the tooltip paints over the tabs and search field
https://github.com/user-attachments/assets/a6d9fe5c-5b7a-4eb8-af13-d0be8e3c3ae7
After: the tooltip stays under the header (clip edge 228px). With the header slid away, the edge moves to 64px and the tooltip shows in full.
https://github.com/user-attachments/assets/69c687af-2d1d-4116-b2de-87ea4b37db95
What specific scenarios should we cover in automated tests?
These are written on the test branch (tests/unit/ChartTooltipClipTest.tsx, tests/ui/ChartTooltipClipPlacementTest.tsx). The placement test fails on main (the tooltip is pushed back to 0 instead of staying at -20 under the toolbar).
- With a fixed toolbar, the web portal wraps the tooltip in a layer clipped at the measured
clipTop. With no boundary, it renders straight intodocument.bodyas it does today. - With
clipTopset,ChartTooltipdoesn't flip or clamp at the top of the window. Without it, placement matches today's. ChartTooltipClipBoundaryprovides the area's top edge, addstopInsetfor a floating header, moves the edge with the header's shift once it has slid away, and provides nothing when disabled.
@rojiphil Thank you for the review! Here is the test branch rebased on latest main (29381d5c):
- Test branch: https://github.com/danlopes18-ctrl/App/tree/test/106940-insights-tooltip-portal
- Commit: https://github.com/danlopes18-ctrl/App/commit/a2286900
Implementation summary
- Scoped clipping host (
ChartTooltipPortalHost+ChartTooltipPortalContext):- Wraps the scrollable content container directly below
{!shouldScrollMainHeader && header}insrc/pages/Insights/InsightsDashboard.tsx(enabled={!shouldScrollMainHeader}), applyingstyles.overflowHiddenandstyles.pRelativeonly when enabled. - Web: portals into the host DOM node via
ReactDOM.createPortal(callback ref, avoidingsetStatein effects) and switchesChartTooltip's layer tostyles.pAbsolutewhileChartTooltipAnchor/index.tsxsubtractshostElement.getBoundingClientRect()(x, y)so coordinates stay host-relative and automatically track toolbar height changes / filter wrapping via flexbox. - Native: renders a named
@gorhom/portal<PortalHost name={hostName} />inside the clipping container and passeshostNameto<Portal>inChartTooltipPortal/index.native.tsx;ChartTooltipAnchor/index.native.tsxalready mountshostOriginRefinsideChartTooltipPortal, so native coordinates align to the scoped host out of the box.
- Wraps the scrollable content container directly below
- Prevents side clipping & preserves smooth tuck-under:
ChartTooltipPortalHostmeasureshostWidth/hostHeightviaonLayoutand passes them throughChartTooltipPortalContext.- When scoped,
ChartTooltip.tsxclampsleftstrictly againsthostWidth([0, portalWidth - width]) so tooltips near the left/right edges of the dashboard content pane are never clipped horizontally, and allowstopto slide smoothly negative under the fixed filter toolbar without clamping tosafeAreaTopor flipping below the point. - Toolbar
zIndexis untouched, tooltips are not dismissed on scroll, and pointer events on the clipped region above the host boundary never intercept toolbar clicks.
- Unchanged fallback:
- When
enabled={false}(shouldScrollMainHeaderon narrow layouts) or outsideInsightsDashboard,ChartTooltipPortalContextisnullandChartTooltipPortal,ChartTooltipAnchor, andChartTooltipkeep the existingdocument.body/ root<Portal>behavior unchanged.
- When
Automated tests planned for the PR
- Unit tests verifying
ChartTooltipPortalmounts into the scoped host whenChartTooltipPortalHostis enabled and falls back todocument.body/ root<Portal>when disabled or absent. - Unit tests verifying
ChartTooltipAnchorreports host-relative coordinates inside a scoped host and window coordinates otherwise. - Unit tests verifying
ChartTooltipusesstyles.pAbsolute, clamps horizontally tohostWidth, and allows vertical tuck-under without top clamping when scoped.
Let me know if you'd like any adjustments on the test branch!
Any updates here @rojiphil ?
@danlopes18-ctrl Thanks for the test branch. The Insights host is the right approach.
In addition, please note that search chart view still needs the same host. Wide and narrow Spend both render ChartTooltip under a fixed filter bar, so that tooltip still paints over the toolbar. Wrap those content views in ChartTooltipPortalHost the same way as Insights.
@danlopes18-ctrl proposal LGTM along with the additional comment at https://github.com/Expensify/App/issues/106940#issuecomment-7180973033 🎀👀🎀 C+ reviewed
Triggered auto assignment to @Gonals, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Thank you @rojiphil! Sounds good — I will also wrap the wide and narrow Spend search chart content views in ChartTooltipPortalHost the same way as Insights, and will open the PR as soon as I'm assigned.
Hi @Gonals — gentle ping on this one since it's marked \Overdue. Happy to open the PR right away as soon as it's assigned whenever you have a moment!
@rojiphil @Gonals small process thing here. this issue never got the Help Wanted label, only External, so it never showed up in the Help Wanted list and most contributors never saw it. per the contributing guidelines the flow is Help Wanted first, then proposals get reviewed and one is picked. could we add Help Wanted and give it a normal proposal window before assigning anyone?
small process thing here. This issue never got the
Help Wantedlabel, onlyExternal, so it never showed up in the Help Wanted list and most contributors never saw it. per the contributing guidelines the flow is Help Wanted first, then proposals get reviewed and one is picked.
Sorry for the confusion here. You are right about the process as the Help Wanted label should have been applied.
As Melvin's proposal was missing, I also missed checking the label before reviewing the proposals. I will be careful next time about this.
@mallenexpensify I think it will help if the automation takes care of applying the Help Wanted label on issues like this where external label is applied and Melvin is not going to post a proposal. What do you think?