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

Make the Combobox component nullable by default #3064

Merged
merged 14 commits into from
Mar 29, 2024

Commits on Mar 28, 2024

  1. remove nullable prop

    RobinMalfait committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    f31a424 View commit details
    Browse the repository at this point in the history
  2. prevent selecting active option on blur

    + cleanup and adjust comments
    RobinMalfait committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    70d0173 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6aa5348 View commit details
    Browse the repository at this point in the history
  4. bump TypeScript to 5.4

    This gives us `NoInfer<T>`!
    RobinMalfait committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    21c4094 View commit details
    Browse the repository at this point in the history
  5. simplify types of Combobox

    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.
    RobinMalfait committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    d816300 View commit details
    Browse the repository at this point in the history
  6. re-add nullable to prevent type issues

    But let's mark it as deprecated to hint that something changed.
    RobinMalfait committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    953316e View commit details
    Browse the repository at this point in the history
  7. update changelog

    RobinMalfait committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    e85627c View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2024

  1. improve ByComparator type

    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).
    RobinMalfait committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    fe6e4aa View commit details
    Browse the repository at this point in the history
  2. ensure the by prop type handles multiple values correctly

    This 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.
    RobinMalfait committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    31bf4d9 View commit details
    Browse the repository at this point in the history
  3. type uncontrolled Combobox components correctly

    We have some tests that use uncontrolled components which means that we
    can't infer the type from the `value` type.
    RobinMalfait committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    89a3027 View commit details
    Browse the repository at this point in the history
  4. simplify onChange calls

    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.
    RobinMalfait committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    1079fc9 View commit details
    Browse the repository at this point in the history
  5. correctly type onChange, by adding null

    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`.
    RobinMalfait committed Mar 29, 2024
    Configuration menu
    Copy the full SHA
    1b9efef View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    dc4f6a8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    ad41fc4 View commit details
    Browse the repository at this point in the history