Skip to content

Commit

Permalink
fix(kit): InputInline fix width calculation (#4878)
Browse files Browse the repository at this point in the history
Co-authored-by: a.inkin <a.inkin@tinkoff.ru>
  • Loading branch information
waterplea and a.inkin authored Jul 10, 2023
1 parent fcaac27 commit 7518bf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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)"
/>

0 comments on commit 7518bf8

Please sign in to comment.