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(core): Textfield fix expression change error #8809

Merged
merged 2 commits into from
Sep 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
2 changes: 1 addition & 1 deletion projects/core/components/textfield/select.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {TuiTextfieldBase, TuiTextfieldDirective} from './textfield.directive';
providers: [tuiProvide(TuiTextfieldDirective, TuiSelect)],
hostDirectives: [TuiNativeValidator, TuiAppearance],
host: {
'[id]': 'el.id || autoId',
'[id]': 'textfield.id',
'[attr.data-mode]': 'mode',
'[class._empty]': 'value === ""',
'(input)': '0',
Expand Down
9 changes: 7 additions & 2 deletions projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {NgControl} from '@angular/forms';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {TuiNativeValidator} from '@taiga-ui/cdk/directives/native-validator';
import {tuiInjectId} from '@taiga-ui/cdk/services';
import type {TuiContext, TuiStringHandler} from '@taiga-ui/cdk/types';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {tuiFocusedIn} from '@taiga-ui/cdk/utils/focus';
Expand Down Expand Up @@ -80,12 +81,16 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
protected side = 0;

protected readonly options = inject(TUI_TEXTFIELD_OPTIONS);
protected readonly autoId = tuiInjectId();
protected readonly icons = inject(TUI_COMMON_ICONS);

@ViewChild('vcr', {read: ViewContainerRef, static: true})
public readonly vcr?: ViewContainerRef;

@ContentChild(forwardRef(() => TuiTextfieldDirective), {read: ElementRef})
@ContentChild(forwardRef(() => TuiTextfieldDirective), {
read: ElementRef,
static: true,
})
public readonly el?: ElementRef<HTMLInputElement>;

@Input()
Expand All @@ -100,7 +105,7 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
public readonly focused = computed(() => this.open() || this.focusedIn());

public get id(): string {
return this.el?.nativeElement.id || '';
return this.el?.nativeElement.id || this.autoId;
}

public get size(): TuiSizeL | TuiSizeS {
Expand Down
4 changes: 1 addition & 3 deletions projects/core/components/textfield/textfield.directive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {computed, Directive, inject, Input, signal} from '@angular/core';
import {TuiNativeValidator} from '@taiga-ui/cdk/directives/native-validator';
import {tuiInjectId} from '@taiga-ui/cdk/services';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {
TuiAppearance,
Expand All @@ -25,7 +24,6 @@ export class TuiTextfieldBase {
);

protected readonly textfield = inject(TuiTextfieldComponent);
protected readonly autoId = tuiInjectId();
protected readonly el = tuiInjectElement<HTMLInputElement>();

@Input()
Expand Down Expand Up @@ -71,7 +69,7 @@ export class TuiTextfieldBase {
selector: 'input[tuiTextfield]',
hostDirectives: [TuiNativeValidator, TuiAppearance],
host: {
'[id]': 'el.id || autoId',
'[id]': 'textfield.id',
'[readOnly]': 'readOnly',
'[class._empty]': 'el.value === ""',
'[attr.data-mode]': 'mode',
Expand Down
Loading