Skip to content

Commit 3a4c5dc

Browse files
committed
refactor(tab.directive): migrate disabled to linkedSignal
1 parent fc2ab80 commit 3a4c5dc

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

projects/coreui-angular/src/lib/tabs-2/tab/tab.directive.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Injector,
1111
input,
1212
InputSignal,
13+
linkedSignal,
1314
OnInit,
1415
runInInjectionContext,
1516
signal,
@@ -47,16 +48,9 @@ export class TabDirective implements FocusableOption, OnInit {
4748
*/
4849
readonly disabledInput = input(false, { transform: booleanAttribute, alias: 'disabled' });
4950

50-
readonly #disabled = signal(false);
51+
readonly #disabled = linkedSignal(this.disabledInput);
5152
readonly attrDisabled = computed(() => this.#disabled() || null);
5253

53-
readonly #disabledEffect = effect(() => {
54-
const disabled = this.disabledInput();
55-
untracked(() => {
56-
this.disabled = disabled;
57-
});
58-
});
59-
6054
set disabled(value: boolean) {
6155
this.#disabled.set(value);
6256
}
@@ -90,11 +84,13 @@ export class TabDirective implements FocusableOption, OnInit {
9084

9185
readonly isActive = signal(false);
9286

93-
readonly hostClasses = computed(() => ({
94-
'nav-link': true,
95-
active: this.isActive(),
96-
disabled: this.#disabled()
97-
}) as Record<string, boolean>);
87+
readonly hostClasses = computed(() => {
88+
return {
89+
'nav-link': true,
90+
active: this.isActive(),
91+
disabled: this.#disabled()
92+
} as Record<string, boolean>;
93+
});
9894

9995
readonly propId = computed(() => this.id() ?? `${this.#tabsService.id()}-tab-${this.itemKey()}`);
10096

0 commit comments

Comments
 (0)