Skip to content

Commit 88b5498

Browse files
[WC-2638]: Fix combobox issue not triggering onChange event (#1219)
2 parents aad4eb1 + 1c10c37 commit 88b5498

File tree

9 files changed

+23
-30
lines changed

9 files changed

+23
-30
lines changed

packages/pluggableWidgets/combobox-web/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed an issue where the onChange event was not being triggered when selecting an item for the first time.
12+
913
## [2.0.1] - 2024-08-16
1014

1115
### Fixed

packages/pluggableWidgets/combobox-web/package.json

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

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function getProperties(values: ComboboxPreviewProps, defaultProperties: P
4949
"selectionMethod",
5050
"selectAllButton",
5151
"selectAllButtonCaption",
52+
"onChangeDatabaseEvent",
5253
...ASSOCIATION_SOURCE_CONFIG,
5354
...LAZY_LOADING_CONFIG
5455
]);
@@ -59,7 +60,11 @@ export function getProperties(values: ComboboxPreviewProps, defaultProperties: P
5960
hidePropertiesIn(defaultProperties, values, ["attributeBoolean"]);
6061
}
6162
} else if (values.optionsSourceType === "association") {
62-
hidePropertiesIn(defaultProperties, values, ["attributeEnumeration", "attributeBoolean"]);
63+
hidePropertiesIn(defaultProperties, values, [
64+
"attributeEnumeration",
65+
"attributeBoolean",
66+
"onChangeDatabaseEvent"
67+
]);
6368
if (values.optionsSourceAssociationCaptionType === "attribute") {
6469
hidePropertiesIn(defaultProperties, values, ["optionsSourceAssociationCaptionExpression"]);
6570
} else {
@@ -100,6 +105,7 @@ export function getProperties(values: ComboboxPreviewProps, defaultProperties: P
100105
"selectionMethod",
101106
"selectAllButton",
102107
"selectAllButtonCaption",
108+
"onChangeEvent",
103109
...ASSOCIATION_SOURCE_CONFIG
104110
]);
105111
if (values.optionsSourceDatabaseDataSource === null) {

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<caption>Selectable objects</caption>
5151
<description />
5252
</property>
53-
<property key="optionsSourceDatabaseItemSelection" type="selection" dataSource="optionsSourceDatabaseDataSource">
53+
<property key="optionsSourceDatabaseItemSelection" type="selection" dataSource="optionsSourceDatabaseDataSource" onChange="onChangeDatabaseEvent">
5454
<caption>Selection type</caption>
5555
<description />
5656
<selectionTypes>
@@ -314,6 +314,10 @@
314314
<caption>On change action</caption>
315315
<description />
316316
</property>
317+
<property key="onChangeDatabaseEvent" type="action" required="false">
318+
<caption>On change action</caption>
319+
<description />
320+
</property>
317321
<property key="onEnterEvent" type="action" required="false">
318322
<caption>On enter action</caption>
319323
<description />

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

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ActionValue, ListAttributeValue, ObjectItem } from "mendix";
2-
import { executeAction } from "@mendix/widget-plugin-platform/framework/execute-action";
1+
import { ListAttributeValue, ObjectItem } from "mendix";
32
import {
43
ComboboxContainerProps,
54
LoadingTypeEnum,
@@ -24,7 +23,6 @@ export class BaseDatabaseSingleSelector<T extends string | Big> implements Singl
2423
status: Status = "unavailable";
2524
type = "single" as const;
2625
protected _objectsMap: Map<string, ObjectItem> = new Map();
27-
protected onChangeEvent?: ActionValue;
2826
protected lazyLoader: LazyLoadProvider = new LazyLoadProvider();
2927

3028
constructor() {
@@ -33,17 +31,8 @@ export class BaseDatabaseSingleSelector<T extends string | Big> implements Singl
3331
}
3432

3533
updateProps(props: ComboboxContainerProps): void {
36-
const {
37-
captionProvider,
38-
captionType,
39-
clearable,
40-
customContentType,
41-
ds,
42-
filterType,
43-
lazyLoading,
44-
loadingType,
45-
onChangeEvent
46-
} = extractDatabaseProps(props);
34+
const { captionProvider, captionType, clearable, customContentType, ds, filterType, lazyLoading, loadingType } =
35+
extractDatabaseProps(props);
4736

4837
this.lazyLoader.updateProps(ds);
4938
this.options._updateProps({
@@ -54,14 +43,12 @@ export class BaseDatabaseSingleSelector<T extends string | Big> implements Singl
5443
});
5544

5645
this.clearable = clearable;
57-
this.onChangeEvent = onChangeEvent;
5846
this.customContentType = customContentType;
5947
this.lazyLoading = lazyLoading;
6048
this.loadingType = loadingType;
6149
}
6250

6351
setValue(objectId: string | null): void {
6452
this.currentId = objectId;
65-
executeAction(this.onChangeEvent);
6653
}
6754
}

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ThreeStateCheckBoxEnum } from "@mendix/widget-plugin-component-kit/ThreeStateCheckBox";
2-
import { executeAction } from "@mendix/widget-plugin-platform/framework/execute-action";
3-
import { ActionValue, ListAttributeValue, ObjectItem, SelectionMultiValue } from "mendix";
2+
import { ListAttributeValue, ObjectItem, SelectionMultiValue } from "mendix";
43
import {
54
ComboboxContainerProps,
65
LoadingTypeEnum,
@@ -31,7 +30,6 @@ export class DatabaseMultiSelectionSelector implements MultiSelector {
3130
type = "multi" as const;
3231
protected lazyLoader: LazyLoadProvider = new LazyLoadProvider();
3332
private _objectsMap: Map<string, ObjectItem> = new Map();
34-
private onChangeEvent?: ActionValue;
3533

3634
constructor() {
3735
this.caption = new DatabaseCaptionsProvider(this._objectsMap);
@@ -74,7 +72,6 @@ export class DatabaseMultiSelectionSelector implements MultiSelector {
7472
filterType,
7573
lazyLoading,
7674
loadingType,
77-
onChangeEvent,
7875
valueAttribute
7976
} = extractDatabaseProps(props);
8077

@@ -118,7 +115,6 @@ export class DatabaseMultiSelectionSelector implements MultiSelector {
118115
this.customContentType = customContentType;
119116
this.lazyLoading = lazyLoading;
120117
this.loadingType = loadingType;
121-
this.onChangeEvent = onChangeEvent;
122118
this.selectAllButton = props.selectAllButton;
123119
this.selectedItemsStyle = props.selectedItemsStyle;
124120
this.selection = props.optionsSourceDatabaseItemSelection as SelectionMultiValue;
@@ -131,6 +127,5 @@ export class DatabaseMultiSelectionSelector implements MultiSelector {
131127
if (newValue) {
132128
this.selection?.setSelection(newValue);
133129
}
134-
executeAction(this.onChangeEvent);
135130
}
136131
}

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

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
ActionValue,
32
DynamicValue,
43
EditableValue,
54
ListAttributeValue,
@@ -29,14 +28,12 @@ type ExtractionReturnValue = {
2928
filterType: FilterTypeEnum;
3029
lazyLoading: boolean;
3130
loadingType: LoadingTypeEnum;
32-
onChangeEvent?: ActionValue;
3331
valueAttribute: ListAttributeValue<string | Big>;
3432
};
3533

3634
export function extractDatabaseProps(props: ComboboxContainerProps): ExtractionReturnValue {
3735
const attr = props.databaseAttributeString;
3836
const filterType = props.filterType;
39-
const onChangeEvent = props.onChangeEvent;
4037

4138
const ds = props.optionsSourceDatabaseDataSource;
4239
if (!ds) {
@@ -80,7 +77,6 @@ export function extractDatabaseProps(props: ComboboxContainerProps): ExtractionR
8077
filterType,
8178
lazyLoading,
8279
loadingType,
83-
onChangeEvent,
8480
valueAttribute
8581
};
8682
}

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

+1-1
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.0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="Combobox" version="2.0.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

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export interface ComboboxPreviewProps {
133133
selectAllButtonCaption: string;
134134
readOnlyStyle: ReadOnlyStyleEnum;
135135
onChangeEvent: {} | null;
136+
onChangeDatabaseEvent: {} | null;
136137
onEnterEvent: {} | null;
137138
onLeaveEvent: {} | null;
138139
ariaRequired: boolean;

0 commit comments

Comments
 (0)