Skip to content

Conversation

@silviuaavram
Copy link
Collaborator

@silviuaavram silviuaavram commented Jun 19, 2020

What:

Accept null for selectedItem in the TS typings. Also fixed an issue by replacing keysSoFar which was not used anymore in useSelect.

Why:

Fixes #1088.

How:

Add | null to selectedItem (state and prop), defaultSelectedItem and initialSelectedItem for useSelect and useCombobox.

Checklist:

  • Documentation N/A
  • Tests N/A
  • TypeScript Types
  • Flow Types N/A
  • Ready to be merged

@mattrothenberg
Copy link

@silviuaavram Whoops, I totally missed this PR in my notifications 🙈 .

I'll close mine in favor of keeping this one open!

@silviuaavram silviuaavram changed the base branch from master to v6 June 27, 2020 12:10
@silviuaavram silviuaavram merged commit 00a5cdb into v6 Jun 27, 2020
@silviuaavram silviuaavram mentioned this pull request Jun 27, 2020
5 tasks
@silviuaavram silviuaavram deleted the chore/fix-ts-selected-item branch July 5, 2020 18:47
silviuaavram added a commit that referenced this pull request Jul 21, 2020
**What**:

Update downshift to v6.

**Why**:

Introduce breaking changes that fix the issues below.
Fixes #1088.
Fixes #1015.
Fixes #1010.
Fixes #719.

**How**:

**The list of breaking changes:**

BREAKING CHANGE: Update TS typings for `selectedItem` to accept `null` in both `useSelect` and `useCombobox`.

To migrate to the new change, update your types or code if necessary. `selectedItem`, `defaultSelectedItem` and `initialSelectedItem` now have `Item | null` instead of `Item` type. PR with the changes: #1090


BREAKING CHANGE: Update TS typings for `itemToString` to accept `null` for the `item` parameter, in `useSelect` and `useCombobox` + in `Downshift` where this was missing. `useMultipleSelection` type for `itemToString` stays the same as it can't receive `null` as `item`.

To migrate to the new change, update your types or code if necessary. `itemToString: (item: Item) => string` -> `itemToString: (item: Item | null) => string}`. PR with the changes: #1075 #1105


BREAKING CHANGE: Pass `type` to the onChange (onInputValueChange, onHighlightedIndexChange, onSelectedItemChange, onIsOpenChange) handler parameters, as specified in the documentation. Also updated the TS typings to reflect this + `onStateChange` - the `type` parameter was passed but it was not reflected in the TS types.

To migrate to the new change, update your types or code if necessary, better to view the changes in the PR: #985.


BREAKING BEHAVIOUR [useCombobox]: When an item is highlighted by keyboard and user closes the menu using mouse/touch, the item is not selected anymore. The only selection on Blur happens using either Tab / Shift+Tab. PR with the changes: #1109


BREAKING BEHAVIOUR [useCombobox & downshift]: When pressing Escape and the menu is open, only close the menu. When the menu is closed and there is an item selected and/or text in the input, clear the selectedItem and the inputValue. PR with the changes: #719
zackdooley28-sys pushed a commit to zackdooley28-sys/ReactPrimitives that referenced this pull request Jan 15, 2026
**What**:

Update downshift to v6.

**Why**:

Introduce breaking changes that fix the issues below.
Fixes downshift-js/downshift#1088.
Fixes downshift-js/downshift#1015.
Fixes downshift-js/downshift#1010.
Fixes downshift-js/downshift#719.

**How**:

**The list of breaking changes:**

BREAKING CHANGE: Update TS typings for `selectedItem` to accept `null` in both `useSelect` and `useCombobox`.

To migrate to the new change, update your types or code if necessary. `selectedItem`, `defaultSelectedItem` and `initialSelectedItem` now have `Item | null` instead of `Item` type. PR with the changes: downshift-js/downshift#1090


BREAKING CHANGE: Update TS typings for `itemToString` to accept `null` for the `item` parameter, in `useSelect` and `useCombobox` + in `Downshift` where this was missing. `useMultipleSelection` type for `itemToString` stays the same as it can't receive `null` as `item`.

To migrate to the new change, update your types or code if necessary. `itemToString: (item: Item) => string` -> `itemToString: (item: Item | null) => string}`. PR with the changes: downshift-js/downshift#1075 downshift-js/downshift#1105


BREAKING CHANGE: Pass `type` to the onChange (onInputValueChange, onHighlightedIndexChange, onSelectedItemChange, onIsOpenChange) handler parameters, as specified in the documentation. Also updated the TS typings to reflect this + `onStateChange` - the `type` parameter was passed but it was not reflected in the TS types.

To migrate to the new change, update your types or code if necessary, better to view the changes in the PR: downshift-js/downshift#985.


BREAKING BEHAVIOUR [useCombobox]: When an item is highlighted by keyboard and user closes the menu using mouse/touch, the item is not selected anymore. The only selection on Blur happens using either Tab / Shift+Tab. PR with the changes: downshift-js/downshift#1109


BREAKING BEHAVIOUR [useCombobox & downshift]: When pressing Escape and the menu is open, only close the menu. When the menu is closed and there is an item selected and/or text in the input, clear the selectedItem and the inputValue. PR with the changes: downshift-js/downshift#719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ts] selectedItem type definition for controlled usage

3 participants