Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(legacy): MultiSelect fix pristine and updateOn: blur issues #9900

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions projects/legacy/classes/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
@Input()
public pseudoInvalid: boolean | null = null;

// Workaround for legacy control to notify of internal change in case updateOn: 'blur' is used
public readonly update$ = new Subject<void>();

constructor() {
super();

Expand Down Expand Up @@ -89,6 +92,7 @@

public set value(value: T) {
this.updateValue(value);
this.update$.next();
}

public get safeCurrentValue(): T {
Expand Down Expand Up @@ -142,7 +146,7 @@
merge(
control.valueChanges,
control.statusChanges,
(control as any).events || EMPTY,

Check warning on line 149 in projects/legacy/classes/control.ts

View check run for this annotation

codefactor.io / CodeFactor

projects/legacy/classes/control.ts#L149

Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any)
),
),
takeUntilDestroyed(this.destroyRef),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Directive, forwardRef, Optional} from '@angular/core';
import {Directive, inject} from '@angular/core';
import {NG_VALUE_ACCESSOR, NgControl} from '@angular/forms';
import {EMPTY_FUNCTION} from '@taiga-ui/cdk/constants';
import {tuiArrayToggle} from '@taiga-ui/cdk/utils/miscellaneous';
Expand All @@ -7,6 +7,7 @@ import {
TUI_DATA_LIST_HOST,
tuiAsOptionContent,
} from '@taiga-ui/core/components/data-list';
import {AbstractTuiControl} from '@taiga-ui/legacy/classes';
import {TuiMultiSelectOptionComponent} from '@taiga-ui/legacy/components/multi-select-option';
import {PolymorpheusComponent} from '@taiga-ui/polymorpheus';

Expand All @@ -23,20 +24,25 @@ export const TUI_MULTI_SELECT_OPTION = new PolymorpheusComponent(
tuiAsOptionContent(TUI_MULTI_SELECT_OPTION),
{
provide: TUI_DATA_LIST_HOST,
deps: [
NgControl,
[new Optional(), forwardRef(() => TuiMultiSelectComponent)],
],
useFactory: <T>(
control: NgControl,
host: TuiDataListHost<T> | null,
): TuiDataListHost<T> =>
host || {
handleOption: (option) =>
control.control?.setValue(
tuiArrayToggle(control.value || [], option),
),
},
useFactory: <T>(): TuiDataListHost<T> => {
const multiSelect = inject(TuiMultiSelectComponent, {optional: true});
const {control} = inject(NgControl);
const host = inject(AbstractTuiControl, {optional: true});

return (
multiSelect || {
handleOption: (option) => {
if (host) {
host.value = tuiArrayToggle(host.value, option);
} else {
control?.setValue(
tuiArrayToggle(control.value || [], option),
);
}
},
}
);
},
},
{
provide: NG_VALUE_ACCESSOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ textarea:host {
:host-context(tui-text-area._ios) {
padding-left: 0.8125rem; // compensation of unkillable padding in mobile safari
}

:host-context(tui-textarea[data-size='s']),
:host-context(tui-textarea[data-size='m']) {
font: var(--tui-font-text-s);
}

:host-context(tui-textarea[data-size='l']) {
font: var(--tui-font-text-m);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class TuiSelectOptionComponent<T> implements OnInit, DoCheck {
protected readonly context =
injectContext<TuiContext<TemplateRef<Record<string, unknown>>>>();

protected readonly selected$ = merge(
protected readonly selected$ = merge<unknown[]>(
this.abstractControl?.update$ || EMPTY,
this.changeDetection$,
this.control.valueChanges || EMPTY,
tuiTypedFromEvent(this.el, 'animationstart'),
Expand Down
Loading