Skip to content

Commit 057ed0b

Browse files
gjulivanyordan-st
authored andcommitted
fix: triggers filter input change only on input change type
1 parent ba54b80 commit 057ed0b

File tree

9 files changed

+22
-15
lines changed

9 files changed

+22
-15
lines changed

packages/pluggableWidgets/combobox-web/src/Combobox.editorConfig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ export function getProperties(
178178
hidePropertiesIn(defaultProperties, values, ["loadingType"]);
179179
}
180180

181+
if (values.onChangeFilterInputEvent === null) {
182+
hidePropertiesIn(defaultProperties, values, ["filterInputDebounceInterval"]);
183+
}
184+
181185
return defaultProperties;
182186
}
183187

packages/pluggableWidgets/combobox-web/src/Combobox.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,9 @@
337337
<actionVariable key="filterInput" caption="Filter Input" type="String" />
338338
</actionVariables>
339339
</property>
340-
341-
<property key="debounceInterval" type="integer" required="true" defaultValue="200">
340+
<property key="filterInputDebounceInterval" type="integer" required="true" defaultValue="200">
342341
<caption>Debounce interval</caption>
343-
<description>The debounce interval in milliseconds.</description>
342+
<description>The debounce interval for each filter input change event triggered in milliseconds.</description>
344343
</property>
345344
</propertyGroup>
346345
<propertyGroup caption="Accessibility">

packages/pluggableWidgets/combobox-web/src/__tests__/MultiSelection.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ describe("Combo box (Association)", () => {
7676
],
7777
selectedItemsSorting: "none",
7878
customEditability: "default",
79-
customEditabilityExpression: dynamic(false)
79+
customEditabilityExpression: dynamic(false),
80+
filterInputDebounceInterval: 200
8081
};
8182
if (defaultProps.optionsSourceAssociationCaptionType === "expression") {
8283
defaultProps.optionsSourceAssociationCaptionExpression!.get = i => dynamic(`${i.id}`);

packages/pluggableWidgets/combobox-web/src/__tests__/SingleSelection.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ describe("Combo box (Association)", () => {
7979
],
8080
selectedItemsSorting: "none",
8181
customEditability: "default",
82-
customEditabilityExpression: dynamic(false)
82+
customEditabilityExpression: dynamic(false),
83+
filterInputDebounceInterval: 200
8384
};
8485
if (defaultProps.optionsSourceAssociationCaptionType === "expression") {
8586
defaultProps.optionsSourceAssociationCaptionExpression!.get = i => dynamic(`${i.id}`);

packages/pluggableWidgets/combobox-web/src/__tests__/StaticSelection.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ describe("Combo box (Static values)", () => {
7777
],
7878
selectedItemsSorting: "none",
7979
customEditability: "default",
80-
customEditabilityExpression: dynamic(false)
80+
customEditabilityExpression: dynamic(false),
81+
filterInputDebounceInterval: 200
8182
};
8283
if (defaultProps.optionsSourceAssociationCaptionType === "expression") {
8384
defaultProps.optionsSourceAssociationCaptionExpression!.get = i => dynamic(`${i.id}`);

packages/pluggableWidgets/combobox-web/src/hooks/useDownshiftMultiSelectProps.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
UseComboboxProps,
33
UseComboboxReturnValue,
44
UseComboboxState,
5+
UseComboboxStateChange,
56
UseComboboxStateChangeOptions,
67
UseMultipleSelectionReturnValue,
78
useCombobox,
@@ -148,9 +149,9 @@ function useComboboxProps(
148149
selectedItem: null,
149150
inputId: options?.inputId,
150151
labelId: options?.labelId,
151-
onInputValueChange({ inputValue }) {
152+
onInputValueChange({ inputValue, type }: UseComboboxStateChange<string>) {
152153
selector.options.setSearchTerm(inputValue!);
153-
if (selector.onFilterInputChange) {
154+
if (selector.onFilterInputChange && type === useCombobox.stateChangeTypes.InputChange) {
154155
selector.onFilterInputChange(inputValue);
155156
}
156157
},

packages/pluggableWidgets/combobox-web/src/hooks/useDownshiftSingleSelectProps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {
22
UseComboboxProps,
33
UseComboboxReturnValue,
44
UseComboboxState,
5-
UseComboboxStateChange,
65
UseComboboxStateChangeOptions,
6+
UseComboboxStateChange,
77
useCombobox
88
} from "downshift";
99

@@ -29,9 +29,9 @@ export function useDownshiftSingleSelectProps(
2929
onSelectedItemChange({ selectedItem }: UseComboboxStateChange<string>) {
3030
selector.setValue(selectedItem ?? null);
3131
},
32-
onInputValueChange({ inputValue }) {
32+
onInputValueChange({ inputValue, type }: UseComboboxStateChange<string>) {
3333
selector.options.setSearchTerm(inputValue!);
34-
if (selector.onFilterInputChange) {
34+
if (selector.onFilterInputChange && type === useCombobox.stateChangeTypes.InputChange) {
3535
selector.onFilterInputChange(inputValue!);
3636
}
3737
},

packages/pluggableWidgets/combobox-web/src/hooks/useGetSelector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export function useGetSelector(props: ComboboxContainerProps): Selector {
2525
() =>
2626
debounce((filterValue?: string) => {
2727
onInputValueChange(props.onChangeFilterInputEvent, filterValue);
28-
}, props.debounceInterval ?? 200),
29-
[props.onChangeFilterInputEvent, props.debounceInterval]
28+
}, props.filterInputDebounceInterval ?? 200),
29+
[props.onChangeFilterInputEvent, props.filterInputDebounceInterval]
3030
);
3131

3232
if (!selectorRef.current) {

packages/pluggableWidgets/combobox-web/typings/ComboboxProps.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export interface ComboboxContainerProps {
9090
onEnterEvent?: ActionValue;
9191
onLeaveEvent?: ActionValue;
9292
onChangeFilterInputEvent?: ActionValue<{ filterInput: Option<string> }>;
93-
debounceInterval?: number;
93+
filterInputDebounceInterval: number;
9494
ariaRequired: DynamicValue<boolean>;
9595
ariaLabel?: DynamicValue<string>;
9696
clearButtonAriaLabel?: DynamicValue<string>;
@@ -148,7 +148,7 @@ export interface ComboboxPreviewProps {
148148
onEnterEvent: {} | null;
149149
onLeaveEvent: {} | null;
150150
onChangeFilterInputEvent: {} | null;
151-
debounceInterval: number | null;
151+
filterInputDebounceInterval: number | null;
152152
ariaRequired: string;
153153
ariaLabel: string;
154154
clearButtonAriaLabel: string;

0 commit comments

Comments
 (0)