-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
New: custom select dropdown example #2679
Conversation
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.
Look great to me, thanks for digging into that select library.
- We should implement an
onValueChange
as we suggested in Make it easier to replace Select/Dropdown components #2676 (comment) and then update the example. - Keyboard navigation seems broken, but I can't say if it’s an issue with the original library.
const { options, value, onChange, "aria-label": ariaLabel } = props; | ||
const container = use(ContainerContext); | ||
|
||
const handleValueChange = (newValue: string) => { |
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.
The idea is to add a onValueChange
to the props:
const { options, value, onChange, "aria-label": ariaLabel } = props; | |
const container = use(ContainerContext); | |
const handleValueChange = (newValue: string) => { | |
const { options, value, onValueChange, "aria-label": ariaLabel } = props; | |
const container = use(ContainerContext); | |
const handleValueChange = onValueChange |
Good catch @gpbl |
What's Changed
Dropdown
using a simplified version ofshadcn/ui
's Select.Notes
Using
shadcn/ui
's Select requires adding@radix-ui/react-select
, which brings a lot of dependencies, but are only needed for development to use in the new example.Another possible approach would be implementing a custom
Select
that is very simplified (also missing a lot of accessibility features already provided byradix-ui
) for the example.Demo
CustomDropdown.mov