Skip to content

Commit 0ddee05

Browse files
authored
fix(downshift): spread dropdownProps last (#17089)
1 parent 100fe44 commit 0ddee05

File tree

8 files changed

+68
-18
lines changed

8 files changed

+68
-18
lines changed

packages/react/src/components/ComboBox/ComboBox.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ next element.
5454
Our `Combobox` component utilizes [Downshift](https://www.downshift-js.com/)
5555
under the hood to help provide complex yet accessible custom dropdown
5656
components. We provide access to the built in Downshift features with this prop.
57+
58+
Use with caution: anything you define here overrides the components' internal
59+
handling of that prop. Downshift internals are subject to change, and in some
60+
cases they can not be shimmed to shield you from potentially breaking changes.
61+
5762
For more information, checkout the Downshift prop
5863
[documentation](https://www.downshift-js.com/downshift#props-used-in-examples)
5964

packages/react/src/components/ComboBox/ComboBox.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ export interface ComboBoxProps<ItemType>
188188
disabled?: boolean;
189189

190190
/**
191-
* Additional props passed to Downshift
191+
* Additional props passed to Downshift. Use with caution: anything you define
192+
* here overrides the components' internal handling of that prop. Downshift
193+
* internals are subject to change, and in some cases they can not be shimmed
194+
* to shield you from potentially breaking changes.
192195
*/
193196
downshiftProps?: Partial<UseComboboxProps<ItemType>>;
194197

@@ -598,7 +601,6 @@ const ComboBox = forwardRef(
598601
toggleMenu,
599602
setHighlightedIndex,
600603
} = useCombobox({
601-
...downshiftProps,
602604
items: filterItems(items, itemToString, inputValue),
603605
inputValue: inputValue,
604606
itemToString: (item) => {
@@ -631,6 +633,7 @@ const ComboBox = forwardRef(
631633
isItemDisabled(item, _index) {
632634
return (item as any).disabled;
633635
},
636+
...downshiftProps,
634637
});
635638

636639
const buttonProps = getToggleButtonProps({
@@ -934,7 +937,10 @@ ComboBox.propTypes = {
934937
disabled: PropTypes.bool,
935938

936939
/**
937-
* Additional props passed to Downshift
940+
* Additional props passed to Downshift. Use with caution: anything you define
941+
* here overrides the components' internal handling of that prop. Downshift
942+
* internals are subject to change, and in some cases they can not be shimmed
943+
* to shield you from potentially breaking changes.
938944
*/
939945
downshiftProps: PropTypes.object as React.Validator<
940946
UseComboboxProps<unknown>

packages/react/src/components/Dropdown/Dropdown.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ to the top of the screen. To do this, specify `direction="top"`
9898
Our `Dropdown` component utilizes [Downshift](https://www.downshift-js.com/)
9999
under the hood to help provide complex yet accessible custom dropdown
100100
components. We provide access to the built in Downshift features with this prop.
101+
102+
Use with caution: anything you define here overrides the components' internal
103+
handling of that prop. Downshift internals are subject to change, and in some
104+
cases they can not be shimmed to shield you from potentially breaking changes.
105+
101106
For more information, checkout the Downshift prop
102107
[documentation](https://www.downshift-js.com/downshift#props-used-in-examples)
103108

packages/react/src/components/Dropdown/Dropdown.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ export interface DropdownProps<ItemType>
109109
disabled?: boolean;
110110

111111
/**
112-
* Additional props passed to Downshift
112+
* Additional props passed to Downshift. Use with caution: anything you define
113+
* here overrides the components' internal handling of that prop. Downshift
114+
* internals are subject to change, and in some cases they can not be shimmed
115+
* to shield you from potentially breaking changes.
113116
*/
114117
downshiftProps?: Partial<UseSelectProps<ItemType>>;
115118

@@ -310,7 +313,6 @@ const Dropdown = React.forwardRef(
310313
const { isFluid } = useContext(FormContext);
311314

312315
const selectProps: UseSelectProps<ItemType> = {
313-
...downshiftProps,
314316
items,
315317
itemToString,
316318
initialSelectedItem,
@@ -334,6 +336,7 @@ const Dropdown = React.forwardRef(
334336
}
335337
}
336338
},
339+
...downshiftProps,
337340
};
338341
const dropdownInstanceId = useId();
339342

@@ -659,7 +662,10 @@ Dropdown.propTypes = {
659662
disabled: PropTypes.bool,
660663

661664
/**
662-
* Additional props passed to Downshift
665+
* Additional props passed to Downshift. Use with caution: anything you define
666+
* here overrides the components' internal handling of that prop. Downshift
667+
* internals are subject to change, and in some cases they can not be shimmed
668+
* to shield you from potentially breaking changes.
663669
*/
664670
downshiftProps: PropTypes.object as React.Validator<UseSelectProps<unknown>>,
665671

packages/react/src/components/FluidMultiSelect/FluidMultiSelect.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ FluidMultiSelect.propTypes = {
6969
disabled: PropTypes.bool,
7070

7171
/**
72-
* Additional props passed to Downshift
72+
* Additional props passed to Downshift. Use with caution: anything you define
73+
* here overrides the components' internal handling of that prop. Downshift
74+
* internals are subject to change, and in some cases they can not be shimmed
75+
* to shield you from potentially breaking changes.
7376
*/
7477
downshiftProps: PropTypes.object,
7578

packages/react/src/components/MultiSelect/FilterableMultiSelect.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ export interface FilterableMultiSelectProps<ItemType>
139139
disabled?: boolean;
140140

141141
/**
142-
* Additional props passed to Downshift
142+
* Additional props passed to Downshift. Use with caution: anything you define
143+
* here overrides the components' internal handling of that prop. Downshift
144+
* internals are subject to change, and in some cases they can not be shimmed
145+
* to shield you from potentially breaking changes.
143146
*/
144147
downshiftProps?: UseMultipleSelectionProps<ItemType>;
145148

@@ -599,7 +602,6 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<
599602
}
600603

601604
const { getDropdownProps } = useMultipleSelection<ItemType>({
602-
...downshiftProps,
603605
activeIndex: highlightedIndex,
604606
initialSelectedItems,
605607
selectedItems: controlledSelectedItems,
@@ -615,6 +617,7 @@ const FilterableMultiSelect = React.forwardRef(function FilterableMultiSelect<
615617
}
616618
}
617619
},
620+
...downshiftProps,
618621
});
619622

620623
useEffect(() => {
@@ -965,7 +968,10 @@ FilterableMultiSelect.propTypes = {
965968
disabled: PropTypes.bool,
966969

967970
/**
968-
* Additional props passed to Downshift
971+
* Additional props passed to Downshift. Use with caution: anything you define
972+
* here overrides the components' internal handling of that prop. Downshift
973+
* internals are subject to change, and in some cases they can not be shimmed
974+
* to shield you from potentially breaking changes.
969975
*/
970976
// @ts-ignore
971977
downshiftProps: PropTypes.shape(Downshift.propTypes),

packages/react/src/components/MultiSelect/MultiSelect.mdx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as MultiSelect from './MultiSelect.stories';
1212

1313
{/* <!-- START doctoc generated TOC please keep comment here to allow auto update --> */}
1414
{/* <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> */}
15+
1516
## Table of Contents
1617

1718
- [Overview](#overview)
@@ -25,11 +26,10 @@ import * as MultiSelect from './MultiSelect.stories';
2526

2627
## Overview
2728

28-
The `MultiSelect` component is a variant of the `Dropdown` component that allows for
29-
multiple items to be selected. `MultiSelect` stays open while items are
29+
The `MultiSelect` component is a variant of the `Dropdown` component that allows
30+
for multiple items to be selected. `MultiSelect` stays open while items are
3031
being selected.
3132

32-
3333
<Canvas>
3434
<Story of={MultiSelect.Default} />
3535
</Canvas>
@@ -44,8 +44,8 @@ By passing items into the `initialSelectedItems` prop, they can be pre-selected.
4444

4545
### Filtering
4646

47-
The `FilterableMultiSelect` component allows for filtering the list of selectable
48-
items to a subset.
47+
The `FilterableMultiSelect` component allows for filtering the list of
48+
selectable items to a subset.
4949

5050
<Canvas>
5151
<Story of={MultiSelect.Filterable} />
@@ -59,6 +59,19 @@ items to a subset.
5959

6060
## Component API
6161

62+
### `downshiftProps`
63+
64+
This component utilizes [Downshift](https://www.downshift-js.com/) under the
65+
hood to help provide complex yet accessible custom dropdown components. We
66+
provide access to the built in Downshift features with this prop.
67+
68+
Use with caution: anything you define here overrides the components' internal
69+
handling of that prop. Downshift internals are subject to change, and in some
70+
cases they can not be shimmed to shield you from potentially breaking changes.
71+
72+
For more information, checkout the Downshift prop
73+
[documentation](https://www.downshift-js.com/downshift#props-used-in-examples)
74+
6275
<ArgsTable />
6376

6477
## Feedback

packages/react/src/components/MultiSelect/MultiSelect.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ export interface MultiSelectProps<ItemType>
136136
disabled?: ListBoxProps['disabled'];
137137

138138
/**
139-
* Additional props passed to Downshift
139+
* Additional props passed to Downshift. Use with caution: anything you define
140+
* here overrides the components' internal handling of that prop. Downshift
141+
* internals are subject to change, and in some cases they can not be shimmed
142+
* to shield you from potentially breaking changes.
140143
*/
141144
downshiftProps?: Partial<UseSelectProps<ItemType>>;
142145

@@ -397,7 +400,6 @@ const MultiSelect = React.forwardRef(
397400
}, [items]);
398401

399402
const selectProps: UseSelectProps<ItemType> = {
400-
...downshiftProps,
401403
stateReducer,
402404
isOpen,
403405
itemToString: (filteredItems) => {
@@ -416,6 +418,7 @@ const MultiSelect = React.forwardRef(
416418
isItemDisabled(item, _index) {
417419
return (item as any).disabled;
418420
},
421+
...downshiftProps,
419422
};
420423

421424
const {
@@ -847,7 +850,10 @@ MultiSelect.propTypes = {
847850
disabled: PropTypes.bool,
848851

849852
/**
850-
* Additional props passed to Downshift
853+
* Additional props passed to Downshift. Use with caution: anything you define
854+
* here overrides the components' internal handling of that prop. Downshift
855+
* internals are subject to change, and in some cases they can not be shimmed
856+
* to shield you from potentially breaking changes.
851857
*/
852858
downshiftProps: PropTypes.object as React.Validator<UseSelectProps<unknown>>,
853859

0 commit comments

Comments
 (0)