Skip to content

Commit 6029f03

Browse files
r0b1ngjulivan
authored andcommitted
chore: keep selection if available
1 parent df896c5 commit 6029f03

File tree

10 files changed

+41
-66
lines changed

10 files changed

+41
-66
lines changed

packages/pluggableWidgets/combobox-web/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212

1313
- We fixed an issue where events from element in footer not directly triggered when input being focused.
1414

15+
- We fixed an issue where combobox selection was reset during search operations (requires Mendix 10.21 or above).
16+
1517
## [2.4.0] - 2025-05-19
1618

1719
### Fixed

packages/pluggableWidgets/combobox-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@mendix/combobox-web",
33
"widgetName": "Combobox",
4-
"version": "2.4.1",
4+
"version": "2.4.2",
55
"description": "Configurable Combo box widget with suggestions and autocomplete.",
66
"copyright": "© Mendix Technology BV 2025. All rights reserved.",
77
"license": "Apache-2.0",

packages/pluggableWidgets/combobox-web/src/helpers/Database/DatabaseMultiSelectionSelector.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export class DatabaseMultiSelectionSelector implements MultiSelector {
121121
this.selectAllButton = props.selectAllButton;
122122
this.selectedItemsStyle = props.selectedItemsStyle;
123123
this.selection = props.optionsSourceDatabaseItemSelection as SelectionMultiValue;
124+
this.selection.setKeepSelection?.(() => true);
124125
this.selectionMethod = props.selectionMethod;
125126
this.selectedItemsSorting = props.selectedItemsSorting;
126127

@@ -133,7 +134,23 @@ export class DatabaseMultiSelectionSelector implements MultiSelector {
133134
}
134135

135136
setValue(value: string[] | null): void {
136-
const newValue = value?.map(v => this.options._optionToValue(v)!);
137+
const newValue = value
138+
?.map(v => {
139+
const knownObject = this.options._optionToValue(v);
140+
if (knownObject) {
141+
return knownObject;
142+
}
143+
144+
// look if this value is in the selection
145+
const selectedObject = this.selection?.selection.find(item => item.id === v);
146+
if (selectedObject) {
147+
return selectedObject;
148+
}
149+
150+
console.warn(`Error setting value: '${v}', not found in options or selection`);
151+
return null;
152+
})
153+
.filter((v): v is ObjectItem => !!v);
137154
if (newValue) {
138155
this.selection?.setSelection(newValue);
139156
}

packages/pluggableWidgets/combobox-web/src/helpers/Database/DatabaseSingleSelectionSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class DatabaseSingleSelectionSelector<T extends string | Big, R extends E
115115
this.status = targetAttribute?.status ?? ds.status;
116116
this.validation = targetAttribute?.validation;
117117
this.selection = props.optionsSourceDatabaseItemSelection as SelectionSingleValue;
118+
this.selection.setKeepSelection?.(() => true);
118119

119120
this.clearable = clearable;
120121
this.customContentType = customContentType;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="Combobox" version="2.4.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="Combobox" version="2.4.2" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="Combobox.xml" />
66
</widgetFiles>

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ export type FilterTypeEnum = "contains" | "containsExact" | "startsWith" | "none
4343

4444
export interface OptionsSourceStaticDataSourcePreviewType {
4545
staticDataSourceValue: string;
46-
staticDataSourceCustomContent: {
47-
widgetCount: number;
48-
renderer: ComponentType<{ children: ReactNode; caption?: string }>;
49-
};
46+
staticDataSourceCustomContent: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
5047
staticDataSourceCaption: string;
5148
}
5249

@@ -130,15 +127,9 @@ export interface ComboboxPreviewProps {
130127
noOptionsText: string;
131128
clearable: boolean;
132129
optionsSourceAssociationCustomContentType: OptionsSourceAssociationCustomContentTypeEnum;
133-
optionsSourceAssociationCustomContent: {
134-
widgetCount: number;
135-
renderer: ComponentType<{ children: ReactNode; caption?: string }>;
136-
};
130+
optionsSourceAssociationCustomContent: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
137131
optionsSourceDatabaseCustomContentType: OptionsSourceDatabaseCustomContentTypeEnum;
138-
optionsSourceDatabaseCustomContent: {
139-
widgetCount: number;
140-
renderer: ComponentType<{ children: ReactNode; caption?: string }>;
141-
};
132+
optionsSourceDatabaseCustomContent: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
142133
staticDataSourceCustomContentType: StaticDataSourceCustomContentTypeEnum;
143134
showFooter: boolean;
144135
menuFooterContent: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };

packages/shared/widget-plugin-filtering/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@mendix/widget-plugin-hooks": "workspace:*",
3939
"@mendix/widget-plugin-platform": "workspace:*",
4040
"downshift": "^9.0.8",
41-
"mendix": "^10.16.49747",
41+
"mendix": "10.23.70273",
4242
"mobx": "6.12.3",
4343
"mobx-react-lite": "4.0.7"
4444
},

packages/shared/widget-plugin-test-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"test": "jest"
3131
},
3232
"dependencies": {
33-
"mendix": "^10.16.49747"
33+
"mendix": "10.23.70273"
3434
},
3535
"devDependencies": {
3636
"@mendix/eslint-config-web-widgets": "workspace:*",

packages/shared/widget-plugin-test-utils/src/builders/SelectionMultiValueBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export class SelectionMultiValueBuilder {
99
selection: [] as ObjectItem[],
1010
setSelection(next: ObjectItem[]) {
1111
this.selection = next;
12-
}
12+
},
13+
setKeepSelection(): void {}
1314
};
1415

1516
this.selectionValue = value as SelectionMultiValue;

pnpm-lock.yaml

Lines changed: 11 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)