Skip to content

Commit

Permalink
fix(legacy): MultiSelect fix for long items overflowing (#9160)
Browse files Browse the repository at this point in the history
Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
waterplea and taiga-family-bot authored Sep 24, 2024
1 parent 8e513a2 commit 80fdfd0
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test.describe('MultiSelect', () => {
});

test('does not overflow arrow icon by many tags', async () => {
const example = documentationPage.getExample('#object-array');
const example = documentationPage.getExample('#objects-array');
const multiSelect = new TuiMultiSelectPO(example.locator('tui-multi-select'));

await multiSelect.textfield.click();
Expand Down Expand Up @@ -67,9 +67,7 @@ test.describe('MultiSelect', () => {
test(`multiselect inside dialog with tuiTextfieldSize=${size}`, async ({
page,
}) => {
const example = documentationPage.getExample(
'#multiselect-inside-dialog-with-different-size',
);
const example = documentationPage.getExample('#inside-dialog');

await example.getByRole('button').nth(index).click();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<tui-multi-select [(ngModel)]="value">
Multiple lines
<tui-data-list-wrapper
*tuiDataList
tuiMultiSelectGroup
[items]="items"
/>
</tui-multi-select>
<p>
<tui-multi-select [(ngModel)]="value">
Scrollable with fade
<tui-data-list-wrapper
*tuiDataList
tuiMultiSelectGroup
[itemContent]="fade"
[items]="items"
/>
<ng-template
#fade
let-item
>
<div
tuiFade
class="fade"
>
{{ item }}
</div>
</ng-template>
</tui-multi-select>
</p>
<tui-multi-select [(ngModel)]="value">
Ellipsis
<tui-data-list-wrapper
*tuiDataList
tuiMultiSelectGroup
[itemContent]="ellipsis"
[items]="items"
/>
<ng-template
#ellipsis
let-item
>
<div class="ellipsis">{{ item }}</div>
</ng-template>
</tui-multi-select>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import '@taiga-ui/core/styles/taiga-ui-local';

.fade {
white-space: nowrap;
}

.ellipsis {
.text-overflow();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiDataListWrapper, TuiFade} from '@taiga-ui/kit';
import {TuiMultiSelectModule} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [FormsModule, TuiDataListWrapper, TuiFade, TuiMultiSelectModule],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
changeDetection,
})
export default class Example {
protected readonly items: readonly string[] = [
'I am a very very long item that definitely overflows',
];

protected value: readonly string[] = [];
}
104 changes: 5 additions & 99 deletions projects/demo/src/modules/components/multi-select/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,105 +10,11 @@
</div>

<tui-doc-example
id="string-array"
heading="String array"
[component]="1 | tuiComponent"
[content]="1 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="object-array"
heading="Custom template, async items loading"
[component]="2 | tuiComponent"
[content]="2 | tuiExample"
/>

<tui-doc-example
id="sizes"
heading="sizes"
[component]="3 | tuiComponent"
[content]="3 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="ids"
heading="With IDs"
[component]="4 | tuiComponent"
[content]="4 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="datalist"
heading="DataList"
[component]="5 | tuiComponent"
[content]="5 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="rtl"
heading="Direction: RTL"
[component]="6 | tuiComponent"
[content]="6 | tuiExample"
/>

<tui-doc-example
id="virtual"
heading="Virtual scroll"
[component]="7 | tuiComponent"
[content]="7 | tuiExample"
[description]="cdkVirtualScrollDescription"
>
<ng-template #cdkVirtualScrollDescription>
You can use
<code>MultiSelect</code>
with
<code>ScrollingModule</code>
from
<a
href="https://material.angular.io/cdk/scrolling/overview"
rel="noreferrer"
target="_blank"
tuiLink
>
&#64;angular/cdk/scrolling
</a>
.
</ng-template>
</tui-doc-example>

<tui-doc-example
id="options-stringify"
heading="Options (stringify)"
[component]="8 | tuiComponent"
[content]="8 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="multiselect-inside-dialog-with-different-size"
heading="Multiselect inside dialog with different textfield sizes"
[component]="9 | tuiComponent"
[content]="9 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="native-select"
heading="Native select"
[component]="10 | tuiComponent"
[content]="10 | tuiExample: 'html,ts'"
/>

<tui-doc-example
id="value-content"
heading="Value content"
[component]="11 | tuiComponent"
[content]="11 | tuiExample"
/>

<tui-doc-example
id="nested-datalist"
heading="Nested datalist"
[component]="12 | tuiComponent"
[content]="12 | tuiExample: 'html,ts'"
*ngFor="let example of examples; let index = index"
[component]="index + 1 | tuiComponent"
[content]="index + 1 | tuiExample"
[heading]="example"
[id]="example | tuiKebab"
/>
</ng-template>

Expand Down
16 changes: 16 additions & 0 deletions projects/demo/src/modules/components/multi-select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ class Account {
],
})
export default class PageComponent extends AbstractExampleTuiControl {
protected readonly examples = [
'Strings array',
'Objects array',
'Sizes',
'With IDs',
'Datalist',
'Direction: RTL',
'Virtual scroll',
'Options (stringify)',
'Inside dialog',
'Native select',
'Value content',
'Nested datalist',
'Long items',
];

protected readonly items = [
new Account('Ruble', 500),
new Account('Dollar', 500),
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/utils/example.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class TuiExamplePipe implements PipeTransform {
format === 'ts' ? 'TypeScript' : format.toUpperCase(),
import(
`../modules/${this.page.type}/${toKebab(this.page.header)}/examples/${index}/index.${format}?raw`
),
).catch(() => ({default: ''})),
]),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

.t-content {
flex: 1;
min-inline-size: 0;
}

.t-loader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
flex: 1;
align-items: center;
animation: retrigger 1s;
overflow: hidden;
}

.t-checkbox {
Expand Down

0 comments on commit 80fdfd0

Please sign in to comment.