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

[Vue] Add null as a possible value for Listbox and ListboxOption in the type definitions #2063

Closed
kerunix opened this issue Dec 5, 2022 Discussed in #2026 · 3 comments · Fixed by #2064
Closed

[Vue] Add null as a possible value for Listbox and ListboxOption in the type definitions #2063

kerunix opened this issue Dec 5, 2022 Discussed in #2026 · 3 comments · Fixed by #2064
Assignees

Comments

@kerunix
Copy link

kerunix commented Dec 5, 2022

Discussed in #2026

Originally posted by kerunix November 17, 2022
Hello there and thank you so much for the great job you're doing at Tailwind Labs, you guys are great !

I'm working on a select menu in a Vue 3 app using Listbox as my base component. My select menu needs to accept null as a possible value. Technically it works at runtime with no problem but Volar is not happy about the type declarations of Listbox.

<!-- inputValue is nullable -->
 <Listbox
    :model-value="inputValue" <!-- Type 'null' is not assignable to type 'string | number | boolean | Record<string, any> | undefined'. -->
  >
     <!-- code -->
</Listbox>

The current type declarations are:

modelValue: { type: [Object, String, Number, Boolean], default: undefined } // For the  Listbox component
value: { type: [Object, String, Number, Boolean] } // For the ListboxOption component

Do you see any problem with adding null as a possible type ?

I'm willing to work on a PR for this if needed although I'm not sure how that would go for the React package since I don't know anything about React.

@RobinMalfait
Copy link
Collaborator

Hey! Thank you for your feature suggestion!
Much appreciated! 🙏

This should be improved by #2064, and will be available in the next release.

You can already try it using npm install @headlessui/vue@insiders.

@kerunix
Copy link
Author

kerunix commented Dec 5, 2022

Hey! Thank you for your feature suggestion! Much appreciated! pray

This should be improved by #2064, and will be available in the next release.

You can already try it using npm install @headlessui/vue@insiders.

I tried it using the insiders version and the issue is only partially fixed since the changes to the typings are working with the model-value prop on the Listbox but they don't seem to apply to the value prop on the ListboxOption component.

Thanks for the quick reaction time !

@RobinMalfait
Copy link
Collaborator

Oops my bad! Updated it for the value prop as well: #2067

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 a pull request may close this issue.

2 participants