Skip to content

Commit fc52120

Browse files
committed
fix: trigger search term updates only for user input
1 parent e915e0e commit fc52120

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

packages/pluggableWidgets/combobox-web/src/components/SingleSelection/SingleSelection.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ export function SingleSelection({
4444
});
4545

4646
const selectedItemCaption = useMemo(
47-
() => selector.caption.render(selectedItem, "label"),
47+
() => selector.caption.render(selector.currentId, "label"),
4848
// eslint-disable-next-line react-hooks/exhaustive-deps
4949
[
50-
selectedItem,
50+
selector.currentId,
5151
selector.status,
5252
selector.caption,
5353
selector.caption.emptyCaption,
54-
selector.currentId,
5554
selector.caption.formatter
5655
]
5756
);

packages/pluggableWidgets/combobox-web/src/helpers/Association/AssociationSingleSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class AssociationSingleSelector
1414
}
1515
setValue(value: string | null): void {
1616
this._attr?.setValue(this.options._optionToValue(value));
17+
this.currentId = value;
1718
super.setValue(value);
1819
}
1920
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ function useComboboxProps(
148148
selectedItem: null,
149149
inputId: options?.inputId,
150150
labelId: options?.labelId,
151-
onInputValueChange({ inputValue }) {
152-
selector.options.setSearchTerm(inputValue!);
153-
154-
if (selector.onFilterInputChange) {
155-
selector.onFilterInputChange(inputValue);
151+
onInputValueChange({ inputValue, type }) {
152+
if (type === useCombobox.stateChangeTypes.InputChange) {
153+
selector.options.setSearchTerm(inputValue!);
154+
if (selector.onFilterInputChange) {
155+
selector.onFilterInputChange(inputValue);
156+
}
156157
}
157158
},
158159
getA11yStatusMessage(options) {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ export function useDownshiftSingleSelectProps(
2929
onSelectedItemChange({ selectedItem }: UseComboboxStateChange<string>) {
3030
selector.setValue(selectedItem ?? null);
3131
},
32-
onInputValueChange({ inputValue }) {
33-
selector.options.setSearchTerm(inputValue!);
34-
35-
if (selector.onFilterInputChange) {
36-
selector.onFilterInputChange(inputValue!);
32+
onInputValueChange({ inputValue, type }) {
33+
if (type === useCombobox.stateChangeTypes.InputChange) {
34+
selector.options.setSearchTerm(inputValue!);
35+
if (selector.onFilterInputChange) {
36+
selector.onFilterInputChange(inputValue!);
37+
}
3738
}
3839
},
3940
getA11yStatusMessage(options) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function useGetSelector(props: ComboboxContainerProps): Selector {
2626
debounce((filterValue?: string) => {
2727
onInputValueChange(props.onChangeFilterInputEvent, filterValue);
2828
}, props.debounceInterval ?? 200),
29-
[props.onChangeFilterInputEvent]
29+
[props.onChangeFilterInputEvent, props.debounceInterval]
3030
);
3131

3232
if (!selectorRef.current) {

0 commit comments

Comments
 (0)