-
Notifications
You must be signed in to change notification settings - Fork 274
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
feat(ui5-li): add text wrapping support #11108
base: main
Are you sure you want to change the base?
Conversation
bf65704
to
10f7b58
Compare
7060ff3
to
166940b
Compare
@property() | ||
declare accessibleName?: string; | ||
@property({ type: Boolean }) | ||
wrapping = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the wrappingType here instead, perhaps making it public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course! I actually considered doing it that way, but for some reason, I didn’t. 😆
07401f2
to
9a78e32
Compare
packages/main/src/List.ts
Outdated
@@ -494,6 +502,7 @@ class List extends UI5Element { | |||
resizeListenerAttached: boolean; | |||
listEndObserved: boolean; | |||
_handleResize: ResizeObserverCallback; | |||
_handleMediaRangeUpdateBound: ResizeObserverCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to re-use the already defined resize handler _handleResize
and wrap the current logic and the _handleMediaRangeUpdate call in a method? This way we won't need to register another resize handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
packages/main/src/List.ts
Outdated
* @private | ||
*/ | ||
@property({ type: String }) | ||
mediaRange!: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to assign type in the decorator, the default one is string. Also, try to provide a default value and move away from the non-null assertion operator (!), perhaps assign a default value "S".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
packages/main/src/ListItem.ts
Outdated
* @private | ||
*/ | ||
@property({ type: String }) | ||
mediaRange!: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for List.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -89,6 +80,27 @@ class ListItemStandard extends ListItem implements IAccessibleListItem { | |||
@property() | |||
additionalTextState: `${ValueState}` = "None"; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Looks like there’s a lot of "noise" changes in this diff due to property reordering and some JSDoc updates.
The icon and iconEnd properties were moved to a different part of the class, leading to big diff blocks. If possible, could you review that for improvements to keep the class history more clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* @private | ||
*/ | ||
get _maxCharacters(): number { | ||
return this.mediaRange === "S" ? 100 : 300; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract those values in a consts, e.g, MAX_CHARACTARES_SIZE_S, MAX_CHARACTARES_SIZE_M
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
function renderTitle(this: ListItemStandard) { | ||
if (this.wrappingType === WrappingType.Normal) { | ||
return ( | ||
<span part="title" class="ui5-li-title"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, this part
will no longer work to restyle the text provided in by the expandable component. What should we do is to introduce a part in the expandable text and use exportparts here to provide it through the list item, you can check if that work in a sample and add the onwers for a review. We can also look into it together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if (this.wrappingType === WrappingType.Normal) { | ||
return ( | ||
<div class="ui5-li-description-info-wrapper"> | ||
<span part="description" class="ui5-li-desc"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, check if exportparts could be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
ca17734
to
8cbd2a5
Compare
The standard list item now supports content wrapping through a new "wrapping" property. When enabled, long text content (title and description) will wrap to multiple lines instead of truncating with an ellipsis. Key features: - Responsive behavior based on screen size: - On mobile (size S): Text truncates after 100 characters - On tablets/desktop (size M/L): Text truncates after 300 characters - "Show More/Less" functionality for very long content using ui5-expandable-text - Works for both title and description fields - CSS styling to ensure proper layout in different states Implementation details: - Added "wrapping" boolean property to ListItemStandard component - Conditionally render content using ExpandableText component when wrapping is enabled - Added _maxCharacters getter to determine truncation point based on media range - Updated ListItemStandardTemplate to handle wrapped content rendering - Added CSS styles to support proper wrapping behavior - Updated HTML test page with examples Documentation: - Added new section in List.mdx explaining the wrapping behavior - Created detailed sample in WrappingBehavior folder - Added JSDoc descriptions for the new property - Added note about deprecated usage of default slot in favor of text property Tests: - Added desktop test for 300 character limit - Added mobile-specific test for 100 character limit - Added test for toggling wrapping property NOTE: This change also promotes the use of the "text" property (added in v2.9.0) instead of the default slot content for setting list item text. The default slot usage is now deprecated and will be removed in a future version.
- Updated the ListItemStandard class and ListItemStandardTemplate - Updated CSS selectors to work with wrapping-type="Normal" attribute - Updated the available test cases - Updated the documentation - Updated the samples
6ab4f6b
to
744e6f1
Compare
Description
The standard list item
ui5-li
now supports content wrapping through a publicly availablewrappingType
property. When set to "Normal", long text content (title and description) will wrap to multiple lines instead of truncating with an ellipsis.Key features:
ui5-expandable-text
Implementation details:
wrappingType
property public available with options "None" (default) and "Normal"ui5-expandable-text
component whenwrappingType
is "Normal"_maxCharacters
getter to determine truncation point based on media rangewrapping-type
attributeDocumentation:
default
slot in favor oftext
propertyTests:
wrappingType
propertyNOTE: This change also promotes the use of the
text
property (added inv2.9.0
) instead of thedefault
slot content for setting list item text. Thedefault
slot usage is now deprecated and will be removed in a future version.Implements: #9745