Skip to content

Commit cf1310d

Browse files
committed
fix(combobox): respect minimum popover width when trigger is narrow
1 parent 58243b0 commit cf1310d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

gem/lib/ruby_ui/combobox/combobox_controller.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { computePosition, autoUpdate, offset, flip } from "@floating-ui/dom";
44
// Connects to data-controller="ruby-ui--combobox"
55
export default class extends Controller {
66
static values = {
7-
term: String
7+
term: String,
8+
minPopoverWidth: { type: Number, default: 240 }
89
}
910

1011
static targets = [
@@ -186,6 +187,7 @@ export default class extends Controller {
186187
}
187188

188189
updatePopoverWidth() {
189-
this.popoverTarget.style.width = `${this.triggerTarget.offsetWidth}px`
190+
const width = Math.max(this.triggerTarget.offsetWidth, this.minPopoverWidthValue)
191+
this.popoverTarget.style.width = `${width}px`
190192
}
191193
}

0 commit comments

Comments
 (0)