ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

[Text]: Word Break instead of Ellipsis for Single Line Text

Open texttechne opened this issue 11 months ago • 12 comments

Bug Description

UI5's Text control allow to set wrapping="false" which then implements the typical ellipsis. Previous versions of Text (prior to 2.0) which probably relied on UI5WC-React also supported this by wrappingType="None".

The current implementation only allows to set maxLines=1. Doing this will also show an ellipsis, but it is implemented via word break. This can lead to very suprising text display.

Example: Edit the code sample on https://sap.github.io/ui5-webcomponents/components/Text/

<ui5-text max-lines="1" style="width: 6rem">Simple Texttttttttttttttttttttttttttttttttttttt</ui5-text>

Result: Simple...

Since the second word is too long for the provided width, the text breaks at the word level. This behavior is correct for text spanning multiple lines. However, for single line text it is a bug. Imagine any scenario with limited space (mobile devices come to mind) and an unfortunate combination of long words (over which we usually don't have any control).

Affected Component

Text

Expected Behaviour

For single line text the classical ellipsis behavior should apply. Take Label as example of this behavior.

Behaves like UI5 does. Example: https://ui5.sap.com/#/entity/sap.m.Text/sample/sap.m.sample.Text/code View.xml:

<mvc:View
	xmlns="sap.m"
	xmlns:mvc="sap.ui.core.mvc">
	<VBox class="sapUiSmallMargin">
		<Text wrapping="false" width="6rem" text="Simple Texttttttttttttttttttttttttttttttttttttt" />
	</VBox>
</mvc:View>

Isolated Example

No response

Steps to Reproduce

...

Log Output, Stack Trace or Screenshots

No response

Priority

None

UI5 Web Components Version

2.x

Browser

Chrome

Operating System

No response

Additional Context

No response

Organization

No response

Declaration

  • [x] I’m not disclosing any internal or sensitive information.

texttechne avatar Jan 30 '25 14:01 texttechne

Hello @texttechne ,

Text wrapping is dependant on the -webkit-line-clamp property - https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp, which seems to not display partial words in most of the cases. To override this behaviour, you can set the styles as follows:

<ui5-text style="width: 6rem; display: inline-block; white-space: nowrap; text-overflow: ellipsis;">Simple Texttttttttttttttttttttttttttttttttttttt</ui5-text>

Does this work for you?

Best regards, Petar

dimovpetar avatar Jan 31 '25 09:01 dimovpetar

Hi @dimovpetar,

sure, works. Thanks!

But we agree, that this should apply automatically for single line text?

Best Regards

texttechne avatar Jan 31 '25 10:01 texttechne

@texttechne this is now the default behavior for single line texts :)

dimovpetar avatar Feb 21 '25 12:02 dimovpetar

:tada: This issue has been resolved in version v2.8.0-rc.3 :tada:

The release is available on v2.8.0-rc.3

Your semantic-release bot :package::rocket:

ui5-webcomponents-bot avatar Feb 27 '25 08:02 ui5-webcomponents-bot

Hi @dimovpetar, thank you very much! Much appreciated!

texttechne avatar Feb 28 '25 11:02 texttechne

Hi @dimovpetar,

This fix introduces regression when using text in ui5-table: check here

Could you please check?

nnaydenow avatar Apr 24 '25 08:04 nnaydenow

Hi @dimovpetar

do we have a timeline, when can we expect the fix since it's affecting us. Thank you. :)

arijitpatra-sap avatar May 05 '25 12:05 arijitpatra-sap

Hello @SAP/ui5-webcomponents-table ,

Seems that using cell item with white-space: nowrap style breaks the layout. See test sample here. Can this be avoided?

Best regards, Petar

dimovpetar avatar May 29 '25 11:05 dimovpetar

@dimovpetar I believe this question is related to the compat/Table, and not something that @SAP/ui5-webcomponents-table is responsible for.

aborjinik avatar Jun 01 '25 15:06 aborjinik

Correct, this is the compatibility table.

dimovpetar avatar Jun 02 '25 06:06 dimovpetar

Hi @arijitpatra-sap,

Do you set width to the specific column? If yes, you can replace the width with max-width to the specific cell as a workaround until we provide a fix.

Regards, Nayden

nnaydenow avatar Jun 02 '25 12:06 nnaydenow

Hi @nnaydenow , thanks for suggesting this approach, I tried this earlier and it works, but I ultimately went ahead with another solution for a temporary fix. Let me know once it is done, I will revert my temporary fix. Thank you.

arijitpatra-sap avatar Jun 02 '25 15:06 arijitpatra-sap