Skip to content

[Typings] Field type missing from useCombobox / useSelect 's props.onStateChange #1015

@andrei-datcu

Description

@andrei-datcu
  • downshift version: 5.2.0

Problem description:
According to the docs:

changes: These are the properties that actually have changed since the last state change. This also has a type property which you can learn more about in the stateChangeTypes section.

Yet in index.d.ts:

onStateChange?: (changes: Partial<UseComboboxState<Item>>) => void

export interface UseComboboxState<Item> {
  highlightedIndex: number
  selectedItem: Item
  isOpen: boolean
  inputValue: string
}

There's no type field

Suggested solution:
The field seems to be present for useMultipleSelection:

  onStateChange?: (changes: UseMultipleSelectionStateChange<Item>) => void

export interface UseMultipleSelectionStateChange<Item>
  extends Partial<UseMultipleSelectionState<Item>> {
  type: UseMultipleSelectionStateChangeTypes
}

So I guess creating two new interfaces that are extending the Use.*State interfaces seems the most consistent option.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions