Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions packages/components/tree-select/tree-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,17 @@ export class KbqTreeSelect

this.selectionModel = tree.selectionModel = new SelectionModel<any>(this.multiSelection);

this.selectionModel.changed.subscribe(() => {
this.selectionModel.changed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
this.onChange(this.selectedValues);

if (this.multiSelection) {
this.refreshTriggerValues();
}
});

this.selectionModel.changed.pipe(delay(0)).subscribe(() => this.setOverlayPosition());
this.selectionModel.changed
.pipe(delay(0), takeUntilDestroyed(this.destroyRef))
.subscribe(() => this.setOverlayPosition());

// eslint-disable-next-line @angular-eslint/no-lifecycle-call
tree.ngAfterContentInit();
Expand Down Expand Up @@ -1119,6 +1121,12 @@ export class KbqTreeSelect
const itemsCounter = this.trigger().nativeElement.querySelector('.kbq-select__match-hidden-text');
const matcherList = this.trigger().nativeElement.querySelector('.kbq-select__match-list');

if (!itemsCounter || !matcherList) {
this.changeDetectorRef.markForCheck();

return;
}

const itemsCounterShowed = itemsCounter.offsetTop < itemsCounter.offsetHeight;
const itemsCounterWidth: number = Math.floor(itemsCounter.getBoundingClientRect().width);

Expand Down Expand Up @@ -1286,7 +1294,12 @@ export class KbqTreeSelect
private getTotalVisibleItems(): [number, number] {
const triggerClone = this.buildTriggerClone();

this.renderer.setStyle(triggerClone.querySelector('.kbq-select__match-hidden-text'), 'display', 'block');
const hiddenText = triggerClone.querySelector('.kbq-select__match-hidden-text');

if (hiddenText) {
this.renderer.setStyle(hiddenText, 'display', 'block');
}

this.renderer.appendChild(this.trigger().nativeElement, triggerClone);

let visibleItemsCount: number = 0;
Expand Down Expand Up @@ -1437,9 +1450,14 @@ export class KbqTreeSelect

if (!search?.ngControl.valueChanges) return;

search.ngControl.valueChanges.pipe(audit(() => this.tree()!.unorderedOptions.changes)).subscribe((value) => {
this.isEmptySearchResult = !!value && this.tree()!.isEmpty;
this.changeDetectorRef.markForCheck();
});
search.ngControl.valueChanges
.pipe(
audit(() => this.tree()!.unorderedOptions.changes),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((value) => {
this.isEmptySearchResult = !!value && this.tree()!.isEmpty;
this.changeDetectorRef.markForCheck();
});
}
}