Skip to content

Commit 64c8da8

Browse files
authored
Fix icons not working when using suggest and suggestOptions = { alreadyProcessed: true } (#449)
1 parent 3e19b5d commit 64c8da8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/components/combo-box/combo-box.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,7 @@ export class ChComboBoxRender
288288
@Watch("expanded")
289289
handleExpandedChange(newExpandedValue: boolean) {
290290
if (newExpandedValue && !mobileDevice) {
291-
this.#itemImages = getComboBoxImages(
292-
this.model,
293-
this.#getActualImagePathCallback()
294-
);
291+
this.#setComboBoxIcons();
295292

296293
// Sync the active descendant when expanding the combo-box
297294
this.#syncActiveDescendant();
@@ -350,6 +347,14 @@ export class ChComboBoxRender
350347
this.#valueToItemInfo,
351348
this.#captionToItemInfo
352349
);
350+
351+
// TODO: Add a unit test for this
352+
// The model can change when the combo-box is expanded by having server
353+
// filters. In this case, we need to re-compute the icons
354+
if (this.expanded) {
355+
this.#setComboBoxIcons();
356+
}
357+
353358
// this.#checkIfCurrentSelectedValueIsNoLongerValid();
354359

355360
// This must be the last operation, since it needs to wait for the UI Model
@@ -464,6 +469,13 @@ export class ChComboBoxRender
464469
getControlRegisterProperty("getImagePathCallback", "ch-combo-box-render") ??
465470
DEFAULT_GET_IMAGE_PATH_CALLBACK;
466471

472+
#setComboBoxIcons = () => {
473+
this.#itemImages = getComboBoxImages(
474+
this.model,
475+
this.#getActualImagePathCallback()
476+
);
477+
};
478+
467479
#scheduleFilterProcessing = () => {
468480
this.#applyFilters = true;
469481
};

0 commit comments

Comments
 (0)