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): support text-overflow in tuiTextfield #2657

Merged
merged 1 commit into from
Sep 12, 2022
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 @@ -27,7 +27,7 @@ import {TUI_TEXTFIELD_HOST} from '@taiga-ui/core/tokens';
'[value]': `host.value`,
'(input)': `host.onValueChange($event.target.value)`,
},
styleUrls: [`textfield.style.less`],
styleUrls: [`./textfield.style.less`],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TuiTextfieldComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
:host-context(tui-text-area._focused:not(._readonly))::placeholder {
opacity: 1;
}

&::placeholder,
&:placeholder-shown {
.text-overflow();
}
}

textarea:host {
Expand Down
1 change: 1 addition & 0 deletions projects/core/styles/mixins/textfield.less
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
overflow: hidden;
text-transform: inherit;
resize: none;
text-overflow: ellipsis;

:host[data-mode='onDark'] &,
:host-context(tui-primitive-textfield[data-mode='onDark']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ describe(`Input`, () => {

it(`has custom content (text) + cleaner + hint which dont overlapping each others`, () => {
cy.tuiVisit(
`${INPUT_PAGE_URL}/API?tuiHintContent=Some%20content&tuiTextfieldCleaner=true&tuiTextfieldCustomContent=%3Cspan%3ELongTextContent%3Cspan%3E`,
`${INPUT_PAGE_URL}/API?tuiHintContent=Some content&tuiTextfieldCustomContent=<b>LongTextContent<b>`,
{skipExpectUrl: true},
);

cy.get(`#demoContent`)
Expand Down Expand Up @@ -52,7 +53,7 @@ describe(`Input`, () => {
);

cy.get(`.t-input-wrapper`)
.find(`input`)
.find(`input[tuiTextfield]`)
.focus()
.should(`have.value`, `111`)
.focused()
Expand All @@ -69,26 +70,28 @@ describe(`Input`, () => {
const characters = `big, placeholder, qwerty, jackson, yellow and more`;

cy.viewport(450, 300).tuiVisit(
`components/input/API?tuiMode=null&tuiTextfieldExampleText=${characters}`,
`components/input/API?tuiMode=null&pseudoFocused=true&attr.placeholder=${characters}`,
);

cy.get(`#demoContent`)
.find(`.t-input-wrapper`)
.tuiScrollIntoView()
.find(`input`)
.find(`input[tuiTextfield]`)
.as(`input`);

cy.get(`@input`)
.focus()
.should(`have.value`, `111`)
.focused()
.clear()
.blur()
.matchImageSnapshot(`06-character-descenders`);

cy.get(`@input`)
.type(
`It has been the industry's standard dummy text ever since the 1500s{enter}`,
)
.blur()
.matchImageSnapshot(`07-very-long-text-without-text-ellipsis`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export class ExampleTuiInputComponent extends AbstractExampleTuiControl {

readonly control = new FormControl(`111`, Validators.required);

placeholder = `Field placeholder`;

override readonly customContentVariants = [
`tuiIconSearchLarge`,
`tuiIconCalendarLarge`,
Expand Down
15 changes: 14 additions & 1 deletion projects/demo/src/modules/components/input/input.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,12 @@
[tuiHintDirection]="hintDirection"
[tuiHintAppearance]="hintAppearance"
>
placeholder
Label
<strong>strong text</strong>
<input
tuiTextfield
[attr.placeholder]="placeholder"
/>
</tui-input>
</ng-template>
</tui-doc-demo>
Expand Down Expand Up @@ -277,6 +281,15 @@
<code>SvgService</code>
</a>
</ng-template>
<ng-template
i18n
documentationPropertyName="attr.placeholder"
documentationPropertyMode="input"
documentationPropertyType="string"
[(documentationPropertyValue)]="placeholder"
>
Placeholder
</ng-template>
</tui-doc-documentation>
<inherited-documentation [dropdown]="true"></inherited-documentation>
</ng-template>
Expand Down