From 416dd8bf28e20f7b8b600acfa771b5c1bef18308 Mon Sep 17 00:00:00 2001 From: Alexey <47535336+dequubi@users.noreply.github.com> Date: Wed, 25 Dec 2024 10:22:07 +0300 Subject: [PATCH] fix(legacy): incorrect InputTag table appearance and PrimitiveTextfield placeholderRaisable calculation (#10052) --- .../modules/components/table/examples/8/index.html | 11 ++++++++++- .../modules/components/table/examples/8/index.ts | 9 ++++++++- .../components/input-tag/input-tag.component.ts | 8 ++++++-- .../primitive-textfield.component.ts | 13 ++++++++++--- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/projects/demo/src/modules/components/table/examples/8/index.html b/projects/demo/src/modules/components/table/examples/8/index.html index 3b7a0d077fb0..f03c9f1c20ea 100644 --- a/projects/demo/src/modules/components/table/examples/8/index.html +++ b/projects/demo/src/modules/components/table/examples/8/index.html @@ -11,7 +11,13 @@ tuiTh [resizable]="true" > - Age + Items + + + Balance Description @@ -19,6 +25,9 @@ {{ item.name }} + + Items + >; + protected readonly textfieldOptions = inject(TUI_TEXTFIELD_OPTIONS); protected readonly hintOptions = inject(TuiHintOptionsDirective, {optional: true}); protected readonly controller = inject(TUI_TEXTFIELD_WATCHED_CONTROLLER); protected readonly icons = inject(TUI_COMMON_ICONS); @@ -189,7 +191,7 @@ export class TuiInputTagComponent public get labelOutside(): boolean { const {size, labelOutside} = this.controller; - return size === 's' || labelOutside; + return this.appearance === 'table' || size === 's' || labelOutside; } public get size(): TuiSizeL | TuiSizeS { @@ -273,7 +275,9 @@ export class TuiInputTagComponent } protected get appearance(): string { - return this.controller.appearance; + return this.textfieldOptions.appearance() === 'table' + ? 'table' + : this.controller.appearance; } protected get expandable(): boolean { diff --git a/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts b/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts index 6186dc4f795f..5285c27a6cbf 100644 --- a/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts +++ b/projects/legacy/components/primitive-textfield/primitive-textfield.component.ts @@ -59,8 +59,7 @@ export const TUI_ICON_START_PADDINGS: Record = { '[class._autofilled]': 'autofilled', '[style.--border-start.rem]': 'borderStart', '[style.--border-end.rem]': 'borderEnd', - '[class._label-outside]': - 'options.appearance() === "table" || controller.labelOutside', + '[class._label-outside]': 'labelOutside', '(focusin)': 'onFocused(true)', '(focusout)': 'onFocused(false)', '(transitionstart.capture)': 'transitionStartHandler($event)', @@ -146,6 +145,14 @@ export class TuiPrimitiveTextfieldComponent this.updateValue(value); } + protected get labelOutside(): boolean { + return ( + this.appearance === 'table' || + this.size === 's' || + this.controller.labelOutside + ); + } + protected get size(): TuiSizeL | TuiSizeS { return this.controller.size; } @@ -303,7 +310,7 @@ export class TuiPrimitiveTextfieldComponent } private get placeholderRaisable(): boolean { - return this.size !== 's' && !this.controller.labelOutside; + return !this.labelOutside; } private updateAutofilled(autofilled: boolean): void {