[Improvement] Combobox: configurable popover placement

Merged
PI
4mo ago
+8-5

Related issue

No related issue — small enhancement.

Description

The combobox popover is currently pinned to bottom-start (hardcoded in combobox_controller.js). This makes it awkward to embed a combobox where there's no room below the trigger — e.g. nested inside another popover/menu, or near the bottom of the viewport.

This adds a placement value to the Stimulus controller and a matching placement: argument to the Combobox component, forwarded via data-ruby-ui--combobox-placement-value. It's passed straight to Floating UI's computePosition, so any Floating UI placement works (bottom-start, left-start, top, etc.).

Fully backward compatible: the default stays bottom-start, so existing comboboxes render exactly as before.

# default (unchanged)
RubyUI.Combobox(term: "Categories") { ... }

# open to the left
RubyUI.Combobox(term: "Categories", placement: "left-start") { ... }
BeforeAfter
Popover always opens bottom-startPopover placement is configurable (default still bottom-start)