Skip to content

Commit

Permalink
fix: load initial data on database source
Browse files Browse the repository at this point in the history
  • Loading branch information
gjulivan committed Jan 15, 2025
1 parent cc88b77 commit ffb845b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/combobox-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Fixed

- We fixed an issue where widget failed to show correct caption on initial load of database source.

## [2.1.3] - 2024-12-11

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/combobox-web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mendix/combobox-web",
"widgetName": "Combobox",
"version": "2.1.3",
"version": "2.1.4",
"description": "Configurable Combo box widget with suggestions and autocomplete.",
"copyright": "© Mendix Technology BV 2024. All rights reserved.",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
}
}

// used for initial load of selected value in case options are lazy loaded
loadSelectedValue(attributeValue: string): void {
if (this.lazyLoading && this.ds && this.attributeId) {
const filterCondition = datasourceFilter("containsExact", attributeValue, this.attributeId);
this.ds?.setFilter(filterCondition);
this.ds.setLimit(this.attributeId.length);
}
}

loadMore(): void {
if (this.ds && this.hasMore) {
this.ds.setLimit(this.ds.limit + DEFAULT_LIMIT_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DatabaseSingleSelectionSelector<
customContent,
customContentType,
attribute: valueSourceAttribute,
caption: targetAttribute?.displayValue
caption: this.currentId ? targetAttribute?.displayValue : undefined
});

this.values.updateProps({
Expand All @@ -69,13 +69,17 @@ export class DatabaseSingleSelectionSelector<
if (this.lastSetValue === null || !_valuesIsEqual(this.lastSetValue, targetAttribute.value)) {
if (ds.status === "available") {
this.lastSetValue = this._attr.value;
if (!_valuesIsEqual(this.values.getEmptyValue(), targetAttribute.value)) {
if (targetAttribute.value) {
const obj = this.options.getAll().find(option => {
return _valuesIsEqual(targetAttribute.value, this.values.get(option));
});
if (obj) {
this.currentId = obj;
} else {
if (targetAttribute.value) {
this.options.loadSelectedValue(targetAttribute.value?.toString());
this.lastSetValue = null;
}
this.currentId = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/combobox-web/src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="Combobox" version="2.1.3" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Combobox" version="2.1.4" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Combobox.xml" />
</widgetFiles>
Expand Down

0 comments on commit ffb845b

Please sign in to comment.