Skip to content

Improvement (combobox): respect minimum popover width when trigger is narrow#397

Open
karinevieira wants to merge 1 commit into
ruby-ui:mainfrom
karinevieira:fix_combobox_popover
Open

Improvement (combobox): respect minimum popover width when trigger is narrow#397
karinevieira wants to merge 1 commit into
ruby-ui:mainfrom
karinevieira:fix_combobox_popover

Conversation

@karinevieira
Copy link
Copy Markdown
Contributor

@karinevieira karinevieira commented May 21, 2026

Description

When a RubyUI::Combobox trigger is narrower than the popover's natural content (e.g. a short trigger label like "Status"), the popover shrinks to match the trigger width and cuts off the ComboboxSearchInput placeholder.

updatePopoverWidth currently sets popover.style.width = trigger.offsetWidth + "px" unconditionally, coupling the popover's width to the trigger's width 1:1. The popover content has its own natural minimum that's independent of the trigger.

This PR introduces a minPopoverWidth Stimulus value (default 240) and applies it as a floor inside updatePopoverWidth

The change is monotonic: it only expands popovers that would otherwise be narrower than the floor. Triggers wider than 240px are unaffected (no regression). resize@window already calls updatePopoverWidth, so the floor holds after viewport changes without any new event listeners.

Consumers can override the floor per-instance via the standard Stimulus values API:

render RubyUI::Combobox.new(data: { "ruby-ui--combobox-min-popover-width-value": 320 })
  ...
end 
Before After
Captura de Tela 2026-05-21 às 16 51 13 | Captura de Tela 2026-05-21 às 16 56 50

Summary by cubic

Prevents RubyUI::Combobox popovers from shrinking below a sensible width when the trigger is narrow, avoiding cut-off placeholders and cramped content.

  • Bug Fixes
    • Added minPopoverWidth Stimulus value (default 240) and apply it as a floor in updatePopoverWidth.
    • Popover width is now max(trigger width, minPopoverWidth) and still updates on window resize.
    • Per-instance overrides supported via ruby-ui--combobox-min-popover-width-value.

Written for commit cf1310d. Summary will update on new commits. Review in cubic

@karinevieira karinevieira requested a review from cirdes as a code owner May 21, 2026 20:29
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant