"use client" import * as React from "react" import { Popover as PopoverPrimitive } from "radix-ui" import { getAkashicPortalContainer } from "../../lib/getAkashicPortalContainer" import { cn } from "../../lib/utils" // ABOVE A MODAL AND A FLOATING WINDOW - same reasoning as `ui/select` and `ui/tooltip`. See // `lib/stackingLayers.ts`. import { Z_POPOVER_CLASS } from "../../lib/stackingLayers" /** * The ui/* replacement for `@wordpress/components`' `Popover` - **1 import**, built on Radix. * * THIS ONE IS NOT A MECHANICAL SWAP, AND THE FAILURE IS SILENT. WordPress's legacy `` takes * its anchor from WHERE IT IS MOUNTED, so the existing call site renders it inside the button it * belongs to and toggles it with its own state: * * {visible &&
...
} * * Radix needs a Root that owns the open state and a Trigger or Anchor to position against. Importing * `Popover` from here and leaving that JSX alone TYPECHECKS - `Popover` is the Root - and renders * NOTHING, because there is no Content inside it. The call site has to be restructured: * * * ... * ... * * * That also lifts the bubble out of the `