Skip to content

Commit 599126e

Browse files
authored
aria-disabled for Select (#281)
1 parent 3e1beab commit 599126e

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

lib/ruby_ui/select/select_item.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,24 @@ def default_attrs
3737
{
3838
role: "option",
3939
tabindex: "0",
40-
class: "item group relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
40+
data_value: @value,
41+
aria_selected: "false",
42+
data_orientation: "vertical",
43+
class: [
44+
"item group relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
45+
"focus:bg-accent focus:text-accent-foreground",
46+
"hover:bg-accent hover:text-accent-foreground",
47+
"disabled:pointer-events-none disabled:opacity-50",
48+
"aria-selected:bg-accent aria-selected:text-accent-foreground",
49+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
50+
"aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
51+
],
4152
data: {
4253
controller: "ruby-ui--select-item",
4354
action: "click->ruby-ui--select#selectItem keydown.enter->ruby-ui--select#selectItem keydown.down->ruby-ui--select#handleKeyDown keydown.up->ruby-ui--select#handleKeyUp keydown.esc->ruby-ui--select#handleEsc",
4455
ruby_ui__select_target: "item"
45-
},
46-
data_value: @value,
47-
data_orientation: "vertical",
48-
aria_selected: "false"
56+
}
57+
4958
}
5059
end
5160
end

lib/ruby_ui/select/select_trigger.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,26 @@ def icon
3333

3434
def default_attrs
3535
{
36+
type: "button",
37+
role: "combobox",
3638
data: {
3739
action: "ruby-ui--select#onClick",
3840
ruby_ui__select_target: "trigger"
3941
},
40-
type: "button",
41-
role: "combobox",
4242
aria: {
4343
controls: "radix-:r0:",
4444
expanded: "false",
4545
autocomplete: "none",
4646
haspopup: "listbox",
4747
activedescendant: true
4848
},
49-
class:
50-
"truncate w-full flex h-9 items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
49+
class: [
50+
"truncate w-full flex h-9 items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background",
51+
"placeholder:text-muted-foreground",
52+
"focus:outline-none focus:ring-1 focus:ring-ring",
53+
"disabled:cursor-not-allowed disabled:opacity-50",
54+
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
55+
]
5156
}
5257
end
5358
end

0 commit comments

Comments
 (0)