Skip to content

Commit

Permalink
fix(legacy): incorrect InputTag table appearance and PrimitiveTextfie…
Browse files Browse the repository at this point in the history
…ld placeholderRaisable calculation (#10052)
  • Loading branch information
dequubi authored Dec 25, 2024
1 parent e96d4eb commit 416dd8b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
11 changes: 10 additions & 1 deletion projects/demo/src/modules/components/table/examples/8/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@
tuiTh
[resizable]="true"
>
Age
Items
</th>
<th
tuiTh
[resizable]="true"
>
Balance
</th>
<th tuiTh>Description</th>
</tr>
</thead>
<tbody tuiTbody>
<tr *ngFor="let item of data">
<td tuiTd>{{ item.name }}</td>
<td tuiTd>
<tui-input-tag [(ngModel)]="item.items">Items</tui-input-tag>
</td>
<td tuiTd>
<tui-input
tuiTextfieldPrefix="$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiTable} from '@taiga-ui/addon-table';
import {TuiInputModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';
import {
TuiInputModule,
TuiInputTagModule,
TuiTextfieldControllerModule,
} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [
FormsModule,
NgForOf,
TuiInputModule,
TuiInputTagModule,
TuiTable,
TuiTextfieldControllerModule,
],
Expand All @@ -24,12 +29,14 @@ export default class Example {
{
name: 'Alex Inkin',
balance: 1323525,
items: ['Wallet', 'Phone'],
description:
'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
},
{
name: 'Roman Sedov',
balance: '',
items: ['Wallet'],
description:
'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.',
},
Expand Down
8 changes: 6 additions & 2 deletions projects/legacy/components/input-tag/input-tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
TuiDataListDirective,
} from '@taiga-ui/core/components/data-list';
import {TuiScrollbar} from '@taiga-ui/core/components/scrollbar';
import {TUI_TEXTFIELD_OPTIONS} from '@taiga-ui/core/components/textfield';
import {TuiDropdownFixed, TuiDropdownOpen} from '@taiga-ui/core/directives/dropdown';
import {TuiHintOptionsDirective} from '@taiga-ui/core/directives/hint';
import {TUI_COMMON_ICONS} from '@taiga-ui/core/tokens';
Expand Down Expand Up @@ -119,6 +120,7 @@ export class TuiInputTagComponent
@ViewChild('errorIcon')
protected readonly errorIconTemplate?: TemplateRef<Record<string, unknown>>;

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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export const TUI_ICON_START_PADDINGS: Record<TuiSizeL | TuiSizeS, number> = {
'[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)',
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 416dd8b

Please sign in to comment.