-
Notifications
You must be signed in to change notification settings - Fork 15
fix(deps): update dependency downshift to v8 #565
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
Changes from all commits
faa7151
c18b2ff
623c517
56df08e
0070575
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,9 +181,13 @@ export const useCombobox = < | |
| false | ||
| }; | ||
|
|
||
| case useDownshift.stateChangeTypes.InputFocus: | ||
| // Prevent expansion on focus. | ||
| return { ...state, isOpen: false }; | ||
| case useDownshift.stateChangeTypes.InputClick: | ||
| if (!isAutocomplete) { | ||
| // Prevent input click listbox expansion on non-autocomplete comboboxes. | ||
| changes.isOpen = state.isOpen; | ||
| } | ||
|
|
||
| break; | ||
|
|
||
| case useDownshift.stateChangeTypes.InputKeyDownArrowDown: | ||
| case useDownshift.stateChangeTypes.FunctionOpenMenu: | ||
|
|
@@ -300,7 +304,7 @@ export const useCombobox = < | |
| initialHighlightedIndex: initialActiveIndex, | ||
| onStateChange: handleDownshiftStateChange, | ||
| stateReducer, | ||
| environment: win | ||
| environment: win as any /* HACK around Downshift's addition of Node to environment */ | ||
| }); | ||
|
|
||
| const closeListbox = useCallback(() => { | ||
|
|
@@ -413,7 +417,7 @@ export const useCombobox = < | |
|
|
||
| previousStateRef.current = { | ||
| ...previousStateRef.current, | ||
| type: useDownshift.stateChangeTypes.InputFocus | ||
| type: useDownshift.stateChangeTypes.InputClick | ||
| }; | ||
| } | ||
| }); | ||
|
|
@@ -449,11 +453,11 @@ export const useCombobox = < | |
| }; | ||
|
|
||
| if (isEditable && triggerContainsInput) { | ||
| const handleClick = (event: MouseEvent) => { | ||
| const handleClick = (event: React.MouseEvent) => { | ||
| if (disabled) { | ||
| event.preventDefault(); | ||
| } else if (isAutocomplete) { | ||
| triggerProps.onClick(event); | ||
| triggerProps.onClick && triggerProps.onClick(event); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚲
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it does. Instead of testing for invalid |
||
| } else { | ||
| inputRef.current?.focus(); | ||
| } | ||
|
|
@@ -591,13 +595,7 @@ export const useCombobox = < | |
| ); | ||
|
|
||
| const getInputProps = useCallback<IUseComboboxReturnValue['getInputProps']>( | ||
| ({ | ||
| role = isEditable ? 'combobox' : null, | ||
| 'aria-labelledby': ariaLabeledBy = null, | ||
| onClick, | ||
| onFocus, | ||
| ...other | ||
| } = {}) => { | ||
| ({ role = isEditable ? 'combobox' : null, onClick, onFocus, ...other } = {}) => { | ||
| const inputProps = { | ||
| 'data-garden-container-id': 'containers.combobox.input', | ||
| 'data-garden-container-version': PACKAGE_VERSION, | ||
|
|
@@ -613,11 +611,10 @@ export const useCombobox = < | |
| triggerRef.current?.contains(event.target) && | ||
| event.stopPropagation(); | ||
|
|
||
| return getDownshiftInputProps({ | ||
| return getDownshiftInputProps<any>({ | ||
| ...inputProps, | ||
| disabled, | ||
| role, | ||
| 'aria-labelledby': ariaLabeledBy, | ||
| 'aria-autocomplete': isAutocomplete ? 'list' : undefined, | ||
| onClick: composeEventHandlers(onClick, handleClick), | ||
| ...getFieldInputProps(), | ||
|
|
@@ -672,7 +669,7 @@ export const useCombobox = < | |
| triggerRef.current?.contains(event.target) && | ||
| event.stopPropagation(); | ||
|
|
||
| const handleKeyDown = (event: KeyboardEvent) => { | ||
| const handleKeyDown = (event: React.KeyboardEvent) => { | ||
| if (event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE) { | ||
| setDownshiftSelection(option.value); | ||
| } else { | ||
|
|
@@ -699,7 +696,7 @@ export const useCombobox = < | |
| triggerRef.current?.focus(); | ||
| } | ||
|
|
||
| inputProps.onKeyDown(event); | ||
| inputProps.onKeyDown && inputProps.onKeyDown(event); | ||
| } | ||
| } | ||
| }; | ||
|
|
@@ -716,13 +713,12 @@ export const useCombobox = < | |
| ); | ||
|
|
||
| const getListboxProps = useCallback<IUseComboboxReturnValue['getListboxProps']>( | ||
| ({ role = 'listbox', 'aria-labelledby': ariaLabeledBy = null, ...other }) => | ||
| getDownshiftListboxProps({ | ||
| ({ role = 'listbox', ...other }) => | ||
| getDownshiftListboxProps<any>({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking re:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort of. imo, while well-intended, the associated Downshift PR kind of made a mess out of the getter prop types to the point where there was no reasonable combo that could satisfy what is going on – so I hit the |
||
| 'data-garden-container-id': 'containers.combobox.listbox', | ||
| 'data-garden-container-version': PACKAGE_VERSION, | ||
| ref: listboxRef, | ||
| role, | ||
| 'aria-labelledby': ariaLabeledBy, | ||
| 'aria-multiselectable': isMultiselectable ? true : undefined, | ||
| ...other | ||
| } as IDownshiftListboxProps), | ||
|
|
@@ -772,9 +768,10 @@ export const useCombobox = < | |
| }; | ||
| } | ||
|
|
||
| return getDownshiftOptionProps({ | ||
| return getDownshiftOptionProps<any>({ | ||
| item: option.value, | ||
| index: values.indexOf(option.value), | ||
| 'aria-disabled': undefined, | ||
| 'aria-selected': ariaSelected, | ||
| ...optionProps | ||
| } as IDownshiftOptionProps<OptionValue>); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downshift was throwing console errors for not calling the combobox getters