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(core): Textfield with [content] property has invalid behavior for <input /> #10066

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions projects/core/styles/components/textfield.less
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ tui-textfield {
.t-template {
display: flex;
align-items: center;
color: var(--tui-text-primary);
}

&._with-template input,
&._with-template select {
color: transparent !important;
}
Expand Down
43 changes: 40 additions & 3 deletions projects/demo-cypress/src/tests/textfield.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {TUI_ANIMATIONS_SPEED, TuiRoot, TuiTextfield} from '@taiga-ui/core';
imports: [FormsModule, TuiRoot, TuiTextfield],
template: `
<tui-root>
<tui-textfield [filler]="filler">
<tui-textfield
#textfield
[content]="textfield.focused() ? '' : content"
[filler]="filler"
>
<input
tuiTextfield
[(ngModel)]="initialValue"
Expand All @@ -24,12 +28,15 @@ export class TestTextfield {

@Input()
public filler = '';

@Input()
public content = '';
}

describe('Textfield', () => {
describe('[filler] property', () => {
beforeEach(() => cy.viewport(200, 150));
beforeEach(() => cy.viewport(200, 150));

describe('[filler] property', () => {
describe('with initial value', () => {
['2', '23', '23:', '23:5', '23:59'].forEach((initialValue) => {
it(initialValue, () => {
Expand Down Expand Up @@ -70,4 +77,34 @@ describe('Textfield', () => {
});
});
});

describe('[content] property', () => {
beforeEach(() => {
cy.mount(TestTextfield, {
componentProperties: {
initialValue: '42',
content: 'TOP-SECRET',
},
});
});

it('shows content for untouched field without focused', () => {
nsbarsukov marked this conversation as resolved.
Show resolved Hide resolved
cy.get('tui-textfield').compareSnapshot('[content]-pristine-unfocused');
Copy link
Member Author

@nsbarsukov nsbarsukov Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous behavior:
textfield cy ts- content -pristine-unfocused

Copy link
Member Author

@nsbarsukov nsbarsukov Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior:
textfield cy ts- content -pristine-unfocused

});

it('hides content and show value on focus', () => {
cy.get('input[tuiTextfield]').focus();

cy.get('tui-textfield').compareSnapshot('[content]-focused');
});

it('shows content again after blur', () => {
cy.get('input[tuiTextfield]')
.focus()
.wait(300) // to ensure that all possible operations are finished
.blur();

cy.get('tui-textfield').compareSnapshot('[content]-after-blur');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous behavior:
textfield cy ts- content -after-blur

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New bahavior:
textfield cy ts- content -after-blur

});
});
});
Loading