Skip to content

fix(ui5-textarea): remove symbols encoding when growing #11305

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions packages/main/cypress/specs/TextArea.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,31 @@ describe("TextArea general interaction", () => {
.should("be.equal", initialTextareaSize);
});
});

it("should grow correctly when typing symbols (&)", () => {
cy.mount(<TextArea growing={true} value="&&&" style="width: 100px"></TextArea>);

cy.get("[ui5-textarea]")
.as("textarea");

cy.get("@textarea")
.realClick();

cy.get("@textarea")
.then(textarea => {
const initialTextareaSize = textarea.height();

cy.focused()
.realType("&");

cy.get("@textarea")
.invoke("height")
.should("be.equal", initialTextareaSize);
});
});
});


describe("When having max length set", () => {
it("prevents input when max is reached", () => {
cy.mount(<TextArea maxlength={10}></TextArea>);
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TextArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class TextArea extends UI5Element implements IFormInputElement {
}

_tokenizeText(value: string) {
const tokenizedText = value.replace(/&/gm, "&amp;").replace(/"/gm, "&quot;").replace(/'/gm, "&apos;").replace(/</gm, "<")
const tokenizedText = value.replace(/</gm, "<")
.replace(/>/gm, ">")
.split("\n");

Expand Down
3 changes: 1 addition & 2 deletions packages/main/src/themes/TextArea.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@
max-height: 94vh;
min-height: calc((var(--_textarea_rows) * var(--_ui5_textarea_line_height)) * var(--sapFontSize) + var(--_ui5_textarea_padding_top) + var(--_ui5_textarea_padding_bottom));
word-break: break-all;
padding-top: var(--_ui5_textarea_padding_top);
padding-bottom: var(--_ui5_textarea_padding_bottom);
padding: var(--_ui5_textarea_padding_top) var(--_ui5_textarea_padding_right_and_left) var(--_ui5_textarea_padding_bottom);
font-size: var(--sapFontSize);
font-family: "72override", var(--sapFontFamily);
white-space: pre-wrap;
Expand Down