Skip to content

Commit 79e468c

Browse files
author
Matus Kasak
committed
Removed forgotten commit
1 parent 8f7191b commit 79e468c

2 files changed

Lines changed: 5 additions & 35 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<i>{{ 'dropdown.clear' | translate }}</i>
4949
</button>
5050
<button class="dropdown-item collection-item text-truncate" *ngFor="let listEntry of optionsList; let i = index"
51-
[class.active]="inputFormatter(listEntry) === (currentValue | async) || i === selectedIndex"
51+
[class.active]="i === selectedIndex"
5252
(keydown.enter)="onSelect(listEntry); sdRef.close()" (mousedown)="onSelect(listEntry); sdRef.close()"
5353
title="{{ inputFormatter(listEntry) }}" role="option"
5454
[attr.id]="inputFormatter(listEntry) === (currentValue|async) ? ('combobox_' + id + '_selected') : null">

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,6 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
9595
});
9696
}
9797

98-
/**
99-
* Compute the index of the current form value within optionsList.
100-
* Returns -1 when there is no current value or it cannot be matched.
101-
*/
102-
private getIndexForCurrentValue(): number {
103-
try {
104-
if (!this.optionsList || this.optionsList.length === 0) { return -1; }
105-
const rawVal = this.group?.get(this.model.id)?.value;
106-
if (isEmpty(rawVal)) { return -1; }
107-
108-
let currentStr: string;
109-
if (typeof rawVal === 'string') {
110-
currentStr = rawVal;
111-
} else if (this.useFindAllService) {
112-
currentStr = rawVal?.[this.model.displayKey];
113-
} else {
114-
currentStr = rawVal?.display;
115-
}
116-
if (isEmpty(currentStr)) { return -1; }
117-
118-
return this.optionsList.findIndex((le: any) => this.inputFormatter(le) === currentStr);
119-
} catch {
120-
return -1;
121-
}
122-
}
123-
12498
/**
12599
* Get service and method to use to retrieve dropdown options
126100
*/
@@ -140,21 +114,17 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
140114
tap(() => this.loading = false),
141115
).subscribe((list: PaginatedList<CacheableObject>) => {
142116
this.optionsList = list.page;
143-
if (fromInit && this.model.value) {
144-
this.setCurrentValue(this.model.value, true);
145-
}
117+
if (fromInit && this.model.value) {
118+
this.setCurrentValue(this.model.value, true);
119+
}
146120

147121
this.updatePageInfo(
148122
list.pageInfo.elementsPerPage,
149123
list.pageInfo.currentPage,
150124
list.pageInfo.totalElements,
151125
list.pageInfo.totalPages
152126
);
153-
154-
// Determine which option should be highlighted by default based on current value
155-
const idx = this.getIndexForCurrentValue();
156-
this.selectedIndex = (idx >= 0) ? idx : -1;
157-
127+
this.selectedIndex = 0;
158128
this.cdr.detectChanges();
159129
});
160130
}

0 commit comments

Comments
 (0)