Skip to content

Commit 1ac2d13

Browse files
[MultiSelectAllDisplayer] numeric badge is not showing when type text (#4190)
* * fix display input directive clear text when mode all is activate * * optional injection token
1 parent 8a3ad3a commit 1ac2d13

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

packages/ng/multi-select/displayer/displayer-input.directive.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { DestroyRef, Directive, ElementRef, HostBinding, HostListener, inject, OnInit } from '@angular/core';
22
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
3+
import { ɵeffectWithDeps } from '@lucca-front/ng/core';
34
import { ILuOptionContext, LU_OPTION_CONTEXT } from '@lucca-front/ng/core-select';
5+
import { InputDirective } from '@lucca-front/ng/form-field';
46
import { of } from 'rxjs';
57
import { startWith, switchMap } from 'rxjs/operators';
68
import { LuMultiSelectInputComponent } from '../input';
7-
import { InputDirective } from '@lucca-front/ng/form-field';
9+
import { MULTI_SELECT_WITH_SELECT_ALL_CONTEXT } from '../input/select-all/select-all.models';
810

911
@Directive({
1012
selector: '[luMultiSelectDisplayerInput]',
@@ -19,6 +21,7 @@ import { InputDirective } from '@lucca-front/ng/form-field';
1921
})
2022
export class LuMultiSelectDisplayerInputDirective<T> implements OnInit {
2123
select = inject<LuMultiSelectInputComponent<T>>(LuMultiSelectInputComponent);
24+
readonly selectAllContext = inject(MULTI_SELECT_WITH_SELECT_ALL_CONTEXT, { optional: true });
2225

2326
context = inject<ILuOptionContext<T[]>>(LU_OPTION_CONTEXT);
2427

@@ -76,16 +79,30 @@ export class LuMultiSelectDisplayerInputDirective<T> implements OnInit {
7679
),
7780
);
7881

82+
constructor() {
83+
if (this.selectAllContext) {
84+
ɵeffectWithDeps([this.selectAllContext.mode], (mode) => {
85+
if (mode === 'all') {
86+
this.#clearText();
87+
}
88+
});
89+
}
90+
}
91+
7992
ngOnInit(): void {
8093
this.select.focusInput$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((data?: { keepClue: boolean }) => {
8194
if (!data?.keepClue) {
82-
this.elementRef.nativeElement.value = '';
83-
this.select.clueChanged('');
95+
this.#clearText();
8496
}
8597
this.elementRef.nativeElement.focus();
8698
});
8799
this.select.emptyClue$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
88100
this.elementRef.nativeElement.value = '';
89101
});
90102
}
103+
104+
#clearText() {
105+
this.elementRef.nativeElement.value = '';
106+
this.select.clueChanged('');
107+
}
91108
}

0 commit comments

Comments
 (0)