Skip to content

Bug: AnchoredOverlay cannot constrain its height to the available space #2521

Description

@denysfedorov

Steps to reproduce

  1. Render an AnchoredOverlay with placement="bottom-start" whose content is taller than the space between its target and the bottom of the viewport — a listbox of options, for example.
  2. Position the target low in the page, so only a few dozen pixels remain below it.
  3. Open the overlay.
  4. flip / shift move it upward, over or past the target. A consumer who needs the overlay to stay below its target has to opt out of that by pinning the placement — and the only way left to keep the overlay on screen is to compute a max-height by hand, from target.getBoundingClientRect().bottom against window.innerHeight.
  5. As the target nears the bottom of the viewport that computed height trends to zero. At a 768×1024 viewport I measured two such overlays capped at 67px and max-height: 0px — open, focus-trapped, and effectively unusable.

Expected Behavior

AnchoredOverlay should be able to constrain its own height to the space available at its chosen placement, so it stays usable and scrolls internally, without the consumer computing anything.

floating-ui ships size() for exactly this: it reports availableWidth / availableHeight for the resolved placement, which is normally applied as a max-height on the floating element. That middleware does not appear to be in the chain — the published bundle contains no reference to availableHeight or availableWidth, while flip, shift and autoPlacement are all present — and the public props (placement, offset, onPlacementChange, onShiftChange) offer no way to opt into it.

Either applying size() by default or exposing it as a prop would remove the need for consumers to hand-roll a height cap, which is where the zero-height case comes from.

Related: #2146 (closed) covered the other half of this — large overlays being shifted off the top of the viewport. This is the complementary case: a consumer deliberately pins the placement, and then needs the height constrained rather than the position moved.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions