Skip to content

Commit 9d001df

Browse files
authored
Improve select (#211)
1 parent 6c79d37 commit 9d001df

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/ruby_ui/select/select_content.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(**attrs)
1010
def view_template(&block)
1111
div(**attrs) do
1212
div(
13-
class: "max-h-96 min-w-max overflow-auto rounded-md border bg-background p-1 text-foreground shadow-md animate-out group-data-[ruby-ui--select-open-value=true]/select:animate-in fade-out-0 group-data-[ruby-ui--select-open-value=true]/select:fade-in-0 zoom-out-95 group-data-[ruby-ui--select-open-value=true]/select:zoom-in-95 slide-in-from-top-2", &block
13+
class: "max-h-96 w-full text-wrap overflow-auto rounded-md border bg-background p-1 text-foreground shadow-md animate-out group-data-[ruby-ui--select-open-value=true]/select:animate-in fade-out-0 group-data-[ruby-ui--select-open-value=true]/select:fade-in-0 zoom-out-95 group-data-[ruby-ui--select-open-value=true]/select:zoom-in-95 slide-in-from-top-2", &block
1414
)
1515
end
1616
end

lib/ruby_ui/select/select_controller.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Controller } from "@hotwired/stimulus";
2-
import { computePosition, autoUpdate, offset } from "@floating-ui/dom";
2+
import { computePosition, autoUpdate, offset, flip } from "@floating-ui/dom";
33

44
export default class extends Controller {
55
static targets = ["trigger", "content", "input", "value", "item"];
@@ -121,7 +121,7 @@ export default class extends Controller {
121121
setFloatingElement() {
122122
this.cleanup = autoUpdate(this.triggerTarget, this.contentTarget, () => {
123123
computePosition(this.triggerTarget, this.contentTarget, {
124-
middleware: [offset(4)],
124+
middleware: [offset(4), flip()],
125125
}).then(({ x, y }) => {
126126
Object.assign(this.contentTarget.style, {
127127
left: `${x}px`,

lib/ruby_ui/select/select_value.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def default_attrs
2020
data: {
2121
ruby_ui__select_target: "value"
2222
},
23-
class: "pointer-events-none"
23+
class: "truncate pointer-events-none"
2424
}
2525
end
2626
end

0 commit comments

Comments
 (0)