-
Notifications
You must be signed in to change notification settings - Fork 611
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
fix(InputMenu/Select/SelectMenu): improve types #2471
Conversation
48f3707
to
be339a9
Compare
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.
Thanks a lot for the work!! π
commit: |
Just tried it out and I don't get autocomplete inside |
Sorry yeah I noticed the autocomplete wouldn't work because it's hard to infer the actual key while also defaulting to 'value' when none is set in Please also note when using |
That's awesome! Thanks a lot @yassilah π |
It seems there is an issue in the documentation typecheck about But it might be because items are not typed correctly π¬ |
π Linked issue
Resolves #2470
β Type of change
π Description
To resolve the issue, I added a few type helpers common to all "select-like" components that allow for a better inference of the actual items. I've made sure it works with both
Item[]
andItem[][]
to preserve the correct types when having multiple groups. I've also added aexpectEmitPayloadType
test helper to ensure the actual types that are being emitted based on the props are correct.Before:
After:
It also handles mixed items array, default
valueKey: "value"
forUSelect
and full object item whenvalueKey
isn't set onUSelectMenu
andUInputMenu
.π Checklist