-
Notifications
You must be signed in to change notification settings - Fork 63
New combobox component #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -26,10 +26,6 @@ codeblock: | |||
gems: | |||
- "rouge" | |||
|
|||
combobox: | |||
js_packages: | |||
- "@floating-ui/dom" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great not to have to use any dependencies for dialogs!
@@ -3,7 +3,7 @@ | |||
module RubyUI | |||
class ComboboxInput < Base | |||
def view_template | |||
input(**attrs) | |||
select(**attrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is a great idea to use a hidden select to hold the values and submit the options
} | ||
|
||
this.datalistOptionTargets.forEach((datalistOption) => { | ||
const selectOption = document.createElement("option") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if this would work if the combobox components were loaded using Turbo/async. Relying on JavaScript to create elements might be risky.
|
||
def default_attrs | ||
{ | ||
class: "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 accent-primary", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a good syntax for classes with big strings
classes | focus-visible classes | disabled classes
class: "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 accent-primary", | |
class: [ | |
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background accent-primary", | |
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", | |
"disabled:cursor-not-allowed disabled:opacity-50" | |
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boa, acho que vai ajudar bastante mesmo a manter organizado.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insane!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations, @stephannv! It’s incredible to see that the combobox now supports multiple items.
Converting to draft while we apply the new combobox on a real application. |
Wow this is great!! |
434447b
to
f07ef72
Compare
EDIT:
After some problems with combobox dialog we are keeping the floating-ui popover. I spent 2 days trying to make it work with anchor-positioning polyfill but I got no success due to some anchor-name/position-anchor property strange behavior. Other update: We are using radio/checkbox to control combobox inputs instead of a hidden select.
Screen.Recording.2024-12-04.at.14.51.56.mov
ORIGINAL:
@cirdes asked me to build a combobox with multiselect. I started building a new component (Multiselect) inspired by how
<select multiple>
behaves on mobile browsers, which opens a dialog with options instead a dropdown widget. But after some discussions, Cirdes and I agreed that we should build the new component as an evolution of current combobox. We read some texts and docs and got inspiration from OpenUI combobox proposal: https://open-ui.org/components/combobox.explainer. Floating-ui was removed in favor of native dialog component.Demo:
Screen.Recording.2024-11-29.at.13.57.40.mov