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

types: expand selectedItem to include null #1091

Closed
wants to merge 1 commit into from
Closed

types: expand selectedItem to include null #1091

wants to merge 1 commit into from

Conversation

mattrothenberg
Copy link

What:

Expands the type definition of selectedItem in both the useSelect and useCombobox interfaces so that TS developers can effectively control their downshift instance without having to suppress warnings and compilation errors.

Note that this change isn't necessary (at least I don't think) for useMultipleSelection since passing an empty array effectively controls the Downshift.

Why:
#1088

As per the docs, selectedItem can be either:

  • A value, resulting in a controlled Downshift
  • Null, resulting in a controlled Downshift
  • Undefined, resulting in an uncontrolled Downshift

Up to this point, that second state wasn't possible to achieve in TS land due to type errors.

How:

Expanded the type definition to include null.

Checklist:
I'm not sure which of these are applicable 🤔

  • Documentation
  • Tests
  • TypeScript Types
  • Flow Types
  • Ready to be merged

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.

1 participant