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): MultiSelect empty line when non empty placeholder and valueContent #9127

Merged
merged 2 commits into from
Sep 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,25 @@

await expect(page).toHaveScreenshot('09-multi-select-non-editable.png');
});

test('placeholder with value content', async ({page}) => {
await tuiGoto(
page,
'components/multi-select/API?valueContent$=1&placeholder=test',
);

await multiSelect.arrow.click();

await multiSelect.selectOptions([0]);
await multiSelect.closeDropdown();

await multiSelect.textfield.blur();

await documentationPage.prepareApiPageBeforeScreenshot();

await expect(page).toHaveScreenshot(

Check failure on line 236 in projects/demo-playwright/tests/kit/multi-select/multi-select.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (4 of 4)

[chromium] › tests/kit/multi-select/multi-select.spec.ts:221:13 › MultiSelect › API page › placeholder with value content

1) [chromium] › tests/kit/multi-select/multi-select.spec.ts:221:13 › MultiSelect › API page › placeholder with value content Error: Screenshot comparison failed: 25403 pixels (ratio 0.04 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/multi-select/multi-select.spec.ts-snapshots/10-multi-select-placeholder-with-value-content-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-multi-select-multi-select-MultiSelect-API-page-placeholder-with-value-content-chromium/10-multi-select-placeholder-with-value-content-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-multi-select-multi-select-MultiSelect-API-page-placeholder-with-value-content-chromium/10-multi-select-placeholder-with-value-content-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - 25403 pixels (ratio 0.04 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - captured a stable screenshot - 25403 pixels (ratio 0.04 of all image pixels) are different. 234 | await documentationPage.prepareApiPageBeforeScreenshot(); 235 | > 236 | await expect(page).toHaveScreenshot( | ^ 237 | '10-multi-select-placeholder-with-value-content.png', 238 | ); 239 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/multi-select/multi-select.spec.ts:236:32

Check failure on line 236 in projects/demo-playwright/tests/kit/multi-select/multi-select.spec.ts

View workflow job for this annotation

GitHub Actions / playwright / (4 of 4)

[chromium] › tests/kit/multi-select/multi-select.spec.ts:221:13 › MultiSelect › API page › placeholder with value content

1) [chromium] › tests/kit/multi-select/multi-select.spec.ts:221:13 › MultiSelect › API page › placeholder with value content Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 25403 pixels (ratio 0.04 of all image pixels) are different. Expected: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/snapshots/tests/kit/multi-select/multi-select.spec.ts-snapshots/10-multi-select-placeholder-with-value-content-chromium-linux.png Received: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-multi-select-multi-select-MultiSelect-API-page-placeholder-with-value-content-chromium-retry1/10-multi-select-placeholder-with-value-content-actual.png Diff: /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests-results/tests-kit-multi-select-multi-select-MultiSelect-API-page-placeholder-with-value-content-chromium-retry1/10-multi-select-placeholder-with-value-content-diff.png Call log: - page._expectScreenshot with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - disabled all CSS animations - 25403 pixels (ratio 0.04 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - disabled all CSS animations - captured a stable screenshot - 25403 pixels (ratio 0.04 of all image pixels) are different. 234 | await documentationPage.prepareApiPageBeforeScreenshot(); 235 | > 236 | await expect(page).toHaveScreenshot( | ^ 237 | '10-multi-select-placeholder-with-value-content.png', 238 | ); 239 | }); at /home/runner/work/taiga-ui/taiga-ui/projects/demo-playwright/tests/kit/multi-select/multi-select.spec.ts:236:32
'10-multi-select-placeholder-with-value-content.png',
);
});
});
});
15 changes: 14 additions & 1 deletion projects/kit/components/input-tag/input-tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
import {TuiStringifiableItem} from '@taiga-ui/kit/classes';
import {FIXED_DROPDOWN_CONTROLLER_PROVIDER} from '@taiga-ui/kit/providers';
import {TuiStatus} from '@taiga-ui/kit/types';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {PolymorpheusContent, PolymorpheusOutletDirective} from '@tinkoff/ng-polymorpheus';
import {Observable, timer} from 'rxjs';
import {map, takeUntil} from 'rxjs/operators';

Expand Down Expand Up @@ -171,6 +171,9 @@ export class TuiInputTagComponent
@ContentChild(TuiDataListDirective, {read: TemplateRef})
readonly datalist?: TemplateRef<TuiContextWithImplicit<TuiActiveZoneDirective>>;

@ContentChild(PolymorpheusOutletDirective)
readonly valueContent?: unknown;

@ViewChild('errorIcon')
readonly errorIconTemplate?: TemplateRef<Record<string, unknown>>;

Expand Down Expand Up @@ -305,6 +308,16 @@ export class TuiInputTagComponent
return this.expandable ? this.rows * this.lineHeight : null;
}

get tagsEmpty(): boolean {
return (
((!this.focused || this.inputHidden) &&
!this.value.length &&
!this.search?.trim()?.length &&
!this.placeholder) ||
!!this.valueContent
);
}

@HostListener('focusin.capture.silent')
@HostListener('focusout.capture.silent')
onFocusInOut(): void {
Expand Down
2 changes: 1 addition & 1 deletion projects/kit/components/input-tag/input-tag.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
overflow: hidden;
}

&_empty:not(.t-with-placeholder) {
&_empty {
height: 0;
}

Expand Down
3 changes: 1 addition & 2 deletions projects/kit/components/input-tag/input-tag.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
>
<div
class="t-tags"
[class.t-tags_empty]="(!focused || inputHidden) && !value?.length && !search?.trim()?.length"
[class.t-with-placeholder]="placeholder"
[class.t-tags_empty]="tagsEmpty"
>
<ng-container *ngIf="labelOutside; else text">
<tui-tag
Expand Down
Loading