Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gem/lib/ruby_ui/combobox/combobox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

module RubyUI
class Combobox < Base
def initialize(term: nil, **)
def initialize(term: nil, placement: "bottom-start", **)
@term = term
@placement = placement
super(**)
end

Expand All @@ -19,6 +20,7 @@ def default_attrs
data: {
controller: "ruby-ui--combobox",
ruby_ui__combobox_term_value: @term,
ruby_ui__combobox_placement_value: @placement,
action: "turbo:morph@window->ruby-ui--combobox#updateTriggerContent"
}
}
Expand Down
5 changes: 3 additions & 2 deletions gem/lib/ruby_ui/combobox/combobox_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { computePosition, autoUpdate, offset, flip } from "@floating-ui/dom";
export default class extends Controller {
static values = {
term: String,
minPopoverWidth: { type: Number, default: 240 }
minPopoverWidth: { type: Number, default: 240 },
placement: { type: String, default: "bottom-start" }
}

static targets = [
Expand Down Expand Up @@ -175,7 +176,7 @@ export default class extends Controller {
updatePopoverPosition() {
this.cleanup = autoUpdate(this.triggerTarget, this.popoverTarget, () => {
computePosition(this.triggerTarget, this.popoverTarget, {
placement: 'bottom-start',
placement: this.placementValue,
middleware: [offset(4), flip()],
}).then(({ x, y }) => {
Object.assign(this.popoverTarget.style, {
Expand Down
Loading