"use client"; import { useLayoutEffect, useState, type CSSProperties, type ReactNode } from "react"; import { createPortal } from "react-dom"; /** * Where the advanced-filter panel is drawn. * * With no anchor it stays where it has always been: in the flow of the * message-list column, directly under the header that carries the filter * button. That is the default layout, and nothing about it changes. * * Mountain View moves the filter button up into the global top bar, next to * the search field. Given the anchor the top bar renders under that field, the * panel drops from it instead: same leading edge, same width, directly * below. * * It is portalled to
and positioned from the anchor's box rather than * rendered inside the anchor. Inside the top bar it shared the root stacking * context with the sidebar column, which carries the same z-index and comes * later in the document, so the sidebar painted over the panel's leading half. * At the end of it wins that tie, and it still loses to any dialog * opened afterwards, which is the order one wants. */ export function FilterPanelHost({ anchor, children, }: { anchor: HTMLElement | null; children: ReactNode; }) { const box = useAnchorBox(anchor); const panel = (