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(kit): InputInline fix width calculation #4878

Merged
merged 1 commit into from
Jul 10, 2023
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
11 changes: 10 additions & 1 deletion projects/kit/components/input-inline/input-inline.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class TuiInputInlineComponent
@ViewChild('native')
private readonly native?: ElementRef<HTMLInputElement>;

@ViewChild('text')
private readonly text?: ElementRef<HTMLElement>;

@Input()
maxLength: number | null = null;

Expand Down Expand Up @@ -63,8 +66,14 @@ export class TuiInputInlineComponent
return this.value !== '';
}

/** @deprecated use 'value' setter */
onValueChange(value: string): void {
if (!this.text) {
return;
}

// Sync update so width is calculated immediately
this.text.nativeElement.textContent = value;
this.text.nativeElement.style.textIndent = '';
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<span
#text
class="t-before"
[style.text-indent.px]="indent"
[textContent]="value"
Expand All @@ -23,7 +24,8 @@
[disabled]="computedDisabled"
[readOnly]="readOnly"
[tuiFocusable]="focusable"
[(ngModel)]="value"
[ngModel]="value"
(ngModelChange)="onValueChange($event)"
(scroll)="onScroll()"
(tuiFocusedChange)="onFocused($event)"
/>
Loading