Skip to content

Commit

Permalink
fix(combobox): use enum for state change types
Browse files Browse the repository at this point in the history
  • Loading branch information
a88zach authored Nov 25, 2024
1 parent f2ba3fd commit bf754d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import cx from 'classnames';
import { useCombobox, UseComboboxProps, UseComboboxActions } from 'downshift';
import { useCombobox, UseComboboxProps, UseComboboxActions, UseComboboxStateChangeTypes } from 'downshift';
import PropTypes from 'prop-types';
import React, {
useContext,
Expand Down Expand Up @@ -777,14 +777,14 @@ const ComboBox = forwardRef(
},
onStateChange: ({ type, selectedItem: newSelectedItem }) => {
if (
type === '__item_click__' &&
type === UseComboboxStateChangeTypes.ItemClick &&
!isEqual(selectedItemProp, newSelectedItem)
) {
onChange({ selectedItem: newSelectedItem });
}
if (
type === '__function_select_item__' ||
type === '__input_keydown_enter__'
type === UseComboboxStateChangeTypes.FunctionSelectItem ||
type === UseComboboxStateChangeTypes.InputKeyDownEnter
) {
onChange({ selectedItem: newSelectedItem });
}
Expand Down

0 comments on commit bf754d4

Please sign in to comment.