Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions app/components/ruby_ui/checkbox/checkbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def default_attrs
action: "change->ruby-ui--checkbox-group#onChange change->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
},
class: [
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background accent-primary",
"peer h-4 w-4 shrink-0 rounded-sm border-input ring-offset-background accent-primary",
"disabled:cursor-not-allowed disabled:opacity-50",
"checked:bg-primary checked:text-primary-foreground",
"checked:bg-primary checked:text-primary-foreground dark:checked:bg-secondary checked:text-primary checked:border-primary",
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
]
Expand Down
3 changes: 2 additions & 1 deletion app/components/ruby_ui/combobox/combobox_popover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ def default_attrs
data: {
ruby_ui__combobox_target: "popover",
action: %w[
toggle->ruby-ui--combobox#handlePopoverToggle
keydown.down->ruby-ui--combobox#keyDownPressed
keydown.up->ruby-ui--combobox#keyUpPressed
keydown.enter->ruby-ui--combobox#keyEnterPressed
keydown.esc->ruby-ui--combobox#closeDialog:prevent
keydown.esc->ruby-ui--combobox#closePopover:prevent
resize@window->ruby-ui--combobox#updatePopoverWidth
]
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/ruby_ui/combobox/combobox_trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def default_attrs
data: {
placeholder: @placeholder,
ruby_ui__combobox_target: "trigger",
action: "ruby-ui--combobox#openPopover"
action: "ruby-ui--combobox#togglePopover"
},
aria: {
haspopup: "listbox",
Expand Down
2 changes: 1 addition & 1 deletion app/components/ruby_ui/context_menu/context_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def default_attrs
{
data: {
controller: "ruby-ui--context-menu",
popover_options_value: @options.to_json
ruby_ui__context_menu_options_value: @options.to_json
}
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/ruby_ui/form/form_field_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def default_attrs
data: {
ruby_ui__form_field_target: "error"
},
class: "text-sm font-medium text-destructive"
class: "text-xs font-medium text-destructive"
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/components/ruby_ui/form/form_field_label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def view_template(&)
def default_attrs
{
class: [
"text-sm font-medium leading-none",
"text-sm font-medium leading-none inline-block",
"peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
"peer-aria-disabled:cursor-not-allowed peer-aria-disabled:opacity-70 peer-aria-disabled:pointer-events-none"
]
Expand Down
4 changes: 2 additions & 2 deletions app/components/ruby_ui/input/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def default_attrs
action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
},
class: [
"flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-sm transition-colors border-border",
"flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] border-border ring-0 ring-ring/0",
"placeholder:text-muted-foreground",
"disabled:cursor-not-allowed disabled:opacity-50",
"file:border-0 file:bg-transparent file:text-sm file:font-medium",
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
"focus-visible:outline-none focus-visible:ring-ring/50 focus-visible:ring-2 focus-visible:border-ring focus-visible:shadow-sm",
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
]
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/ruby_ui/radio_button/radio_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def default_attrs
class: [
"h-4 w-4 p-0 border-primary rounded-full flex-none",
"disabled:cursor-not-allowed disabled:opacity-50",
"checked:bg-primary checked:text-primary-foreground",
"checked:bg-primary checked:text-primary-foreground dark:checked:bg-secondary checked:text-primary checked:border-primary",
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
]
}
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import { application } from "./application"

import IframeThemeController from "./iframe_theme_controller"
application.register("iframe-theme", IframeThemeController)

import RubyUi__AccordionController from "./ruby_ui/accordion_controller"
application.register("ruby-ui--accordion", RubyUi__AccordionController)

Expand Down Expand Up @@ -82,8 +85,5 @@ application.register("ruby-ui--theme-toggle", RubyUi__ThemeToggleController)
import RubyUi__TooltipController from "./ruby_ui/tooltip_controller"
application.register("ruby-ui--tooltip", RubyUi__TooltipController)

import IframeThemeController from "./iframe_theme_controller"
application.register("iframe-theme", IframeThemeController)

import SidebarMenuController from "./sidebar_menu_controller"
application.register("sidebar-menu", SidebarMenuController)
17 changes: 16 additions & 1 deletion app/javascript/controllers/ruby_ui/combobox_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default class extends Controller {
if (this.cleanup) { this.cleanup() }
}

handlePopoverToggle(event) {
// Keep ariaExpanded in sync with the actual popover state
this.triggerTarget.ariaExpanded = event.newState === 'open' ? 'true' : 'false'
}

inputChanged(e) {
this.updateTriggerContent()

Expand Down Expand Up @@ -62,9 +67,19 @@ export default class extends Controller {
}
}

openPopover(event) {
togglePopover(event) {
event.preventDefault()

if (this.triggerTarget.ariaExpanded === "true") {
this.closePopover()
} else {
this.openPopover(event)
}
}

openPopover(event) {
if (event) event.preventDefault()

this.updatePopoverPosition()
this.updatePopoverWidth()
this.triggerTarget.ariaExpanded = "true"
Expand Down