-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make the Combobox
component nullable
by default
#3064
Commits on Mar 28, 2024
-
Configuration menu - View commit details
-
Copy full SHA for f31a424 - Browse repository at this point
Copy the full SHA f31a424View commit details -
prevent selecting active option on blur
+ cleanup and adjust comments
Configuration menu - View commit details
-
Copy full SHA for 70d0173 - Browse repository at this point
Copy the full SHA 70d0173View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6aa5348 - Browse repository at this point
Copy the full SHA 6aa5348View commit details -
Configuration menu - View commit details
-
Copy full SHA for 21c4094 - Browse repository at this point
Copy the full SHA 21c4094View commit details -
Now that `nullable` is gone, we can take another look at the type definition. This in combination with the new `NoInfer` type makes types drastically simpler and more correct.
Configuration menu - View commit details
-
Copy full SHA for d816300 - Browse repository at this point
Copy the full SHA d816300View commit details -
re-add
nullable
to prevent type issuesBut let's mark it as deprecated to hint that something changed.
Configuration menu - View commit details
-
Copy full SHA for 953316e - Browse repository at this point
Copy the full SHA 953316eView commit details -
Configuration menu - View commit details
-
Copy full SHA for e85627c - Browse repository at this point
Copy the full SHA e85627cView commit details
Commits on Mar 29, 2024
-
If we are just checking for `T extends null`, then `{id:1,name:string}|null` will also be true and therefore we would eventually return `string` instead of `"id" | "name"`. To solve this, we first check if `NonNullable<T> extends never`, this would be the case if `T` is `null`. Otherwise, we know it's not just `null` but it can be something else with or without `null`. To be sure, we use `keyof NonNullable<null>` to get rid of the `null` part and to only keep the rest of the object (if it's an object).
Configuration menu - View commit details
-
Copy full SHA for fe6e4aa - Browse repository at this point
Copy the full SHA fe6e4aaView commit details -
ensure the
by
prop type handlesmultiple
values correctlyThis way the `by` prop will still compare single values that are present inside the array. This now also solves a pending TypeScript issue that we used to `// @ts-expect-error` before.
Configuration menu - View commit details
-
Copy full SHA for 31bf4d9 - Browse repository at this point
Copy the full SHA 31bf4d9View commit details -
type uncontrolled
Combobox
components correctlyWe have some tests that use uncontrolled components which means that we can't infer the type from the `value` type.
Configuration menu - View commit details
-
Copy full SHA for 89a3027 - Browse repository at this point
Copy the full SHA 89a3027View commit details -
Now that we don't infer the type when using the generic inside of `onChange`, it means that we can use `onChange={setValue}` directly because we don't have to worry about the updater function of `setValue` anymore.
Configuration menu - View commit details
-
Copy full SHA for 1079fc9 - Browse repository at this point
Copy the full SHA 1079fc9View commit details -
correctly type
onChange
, by addingnull
If you are in single value mode, then the `onChange` can (and will) receive `null` as a value (when you clear the input field). We never properly typed it so this fixes that. In multiple value mode this won't happen, if anything the value will be `[]` but not `null`.
Configuration menu - View commit details
-
Copy full SHA for 1b9efef - Browse repository at this point
Copy the full SHA 1b9efefView commit details -
Configuration menu - View commit details
-
Copy full SHA for dc4f6a8 - Browse repository at this point
Copy the full SHA dc4f6a8View commit details -
Configuration menu - View commit details
-
Copy full SHA for ad41fc4 - Browse repository at this point
Copy the full SHA ad41fc4View commit details