Skip to content
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

Merged
merged 10 commits into from
Feb 8, 2025

Conversation

rodgobbi
Copy link
Collaborator

@rodgobbi rodgobbi commented Feb 2, 2025

What's Changed

  • Add an example with Custom Select Dropdown using a simplified version of shadcn/ui's Select.
  • Update Custom Components docs, adding the new example for reference.

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 by radix-ui) for the example.

Demo

CustomDropdown
CustomDropdown.mov

@rodgobbi rodgobbi requested a review from gpbl February 8, 2025 13:16
Copy link
Owner

@gpbl gpbl left a 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.

Comment on lines +18 to +21
const { options, value, onChange, "aria-label": ariaLabel } = props;
const container = use(ContainerContext);

const handleValueChange = (newValue: string) => {
Copy link
Owner

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:

Suggested change
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

@gpbl gpbl merged commit 6005f7d into gpbl:main Feb 8, 2025
11 checks passed
@rodgobbi
Copy link
Collaborator Author

rodgobbi commented Feb 9, 2025

Keyboard navigation seems broken, but I can't say if it’s an issue with the original library.

Good catch @gpbl
I noticed this but missed writing a note about it.
The issue only happens in the docs, when the example is mounted in the doc window sandbox, I don't know if the shadow-dom sandbox causes some issue to radix, but running the example normally on the browser works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants