Feature Request: allow autoPlacement to keep a preferred placement when it fits

Author: weidehaiCreated Jun 9, 2026Updated Jul 11, 2026

Description

Currently, autoPlacement chooses the side with the most available space. This is useful, but in some cases it can move the floating element away from the placement the UI would prefer, even when that preferred placement has enough room to render without clipping.

Use case

I have a preferred placement, for example bottom, because it matches the intended layout and user experience. I still want automatic placement when the preferred side cannot fit.

The desired behavior is:

  1. Try the preferred placement first.
  2. If the floating element fits there, keep that placement.
  3. If it does not fit, fall back to the current autoPlacement behavior and choose the side with the most available space.

In other words, this would preserve the preferred placement when it is viable, while still keeping the adaptive behavior of autoPlacement for constrained layouts.

Possible API

One possible option could be something like:

typescript
autoPlacement({
  preferredPlacement: 'bottom',
});

or another API shape that better matches the existing middleware design.

Willing to contribute

If this feature makes sense for the project, I would be happy to submit a PR to implement it.