question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to preserve `/n` in sap.m.Text

See original GitHub issue

For <span>test \n\n\n test</span>, it showed in page:

image

But for <Text text="test \n\n\n test"/>, it showed as:

image

And \n is not preserved in HTML:

image

As the doc said, I added renderWhitespace="true", maxLines="0":

image

renderWhitespace="false", maxLines="1": image

What if I want to show “test \n\n\n test” ?

Failed to find design purpose for renderWhitespace in https://github.com/SAP/openui5/blob/master/src/sap.m/src/sap/m/Text.js#L184

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jagtrasinghcommented, Feb 26, 2020

if enter new line at starting by pressing enter in TextArea then it removes the new line when we refresh the json model binded with TextArea . Please look into this issue

1reaction
LidiyaGeorgievacommented, May 15, 2018

Issue is fixed in SAPUI5 version 1.56

Read more comments on GitHub >

github_iconTop Results From Across the Web

how do I display \n in sap.m.Text - SAP Community
1. change the control from sap.m.Text to sap.m.Label. 2. write a formatter for the text property to replace the escape ...
Read more >
Text - Documentation - Demo Kit - SAPUI5 SDK
The Text control supports the rendering of new lines and the preservation of whitespace and tabs. Depending on whether you are using JavaScript...
Read more >
How to add a line break to text in UI5? - Stack Overflow
In case the control sap.m.Text is used, keep in mind to enable the properties renderWhitespace and wrapping in order render the new lines...
Read more >
Line break in sap.m.Text • Post • Neptune Software Community
Actually, it seems possible to have line breaks in a single instance of sap.m.Text by using '\r\n'. Using '\n' alone does not do...
Read more >
Title - UI5 Web Components - SAP
None - The text will be truncated with an ellipsis. Normal - The text will wrap. The words will not be broken based...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found