Skip to content

Commit 9a78e32

Browse files
committed
feat(ui5-li): change wrappingType property to public
- 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
1 parent e74153f commit 9a78e32

File tree

8 files changed

+68
-89
lines changed

8 files changed

+68
-89
lines changed

packages/main/cypress/specs/List.cy.tsx

+7-18
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,11 @@ describe("List - Wrapping Behavior", () => {
185185

186186
cy.mount(
187187
<List>
188-
<ListItemStandard id="wrapping-item" wrapping text={longText} description={longDescription}></ListItemStandard>
188+
<ListItemStandard id="wrapping-item" wrappingType="Normal" text={longText} description={longDescription}></ListItemStandard>
189189
</List>
190190
);
191191

192192
// Check wrapping attributes are set correctly
193-
cy.get("#wrapping-item")
194-
.should("have.attr", "wrapping");
195-
196193
cy.get("#wrapping-item")
197194
.should("have.attr", "wrapping-type", "Normal");
198195

@@ -209,7 +206,7 @@ describe("List - Wrapping Behavior", () => {
209206

210207
cy.mount(
211208
<List>
212-
<ListItemStandard id="wrapping-item" wrapping text={longText}></ListItemStandard>
209+
<ListItemStandard id="wrapping-item" wrappingType="Normal" text={longText}></ListItemStandard>
213210
</List>
214211
);
215212

@@ -222,20 +219,16 @@ describe("List - Wrapping Behavior", () => {
222219
.should('eq', 300);
223220
});
224221

225-
it("should switch wrapping type when wrapping prop is toggled", () => {
222+
it("should render different nodes based on wrappingType prop", () => {
226223
const longText = "This is a very long text that should be wrapped when the wrapping prop is enabled, and truncated when it's disabled. This is a very long text that should be wrapped when the wrapping prop is enabled, and truncated when it's disabled. This is a very long text that should be wrapped when the wrapping prop is enabled, and truncated when it's disabled. This is a very long text that should be wrapped when the wrapping prop is enabled, and truncated when it's disabled. This is a very long text that should be wrapped when the wrapping prop is enabled, and truncated when it's disabled. And now we're adding even more text to be extra certain that we have enough content to demonstrate the behavior properly.";
227224

228225
// First render with wrapping enabled
229226
cy.mount(
230227
<List>
231-
<ListItemStandard id="wrapping-item" wrapping text={longText}></ListItemStandard>
228+
<ListItemStandard id="wrapping-item" wrappingType="Normal" text={longText}></ListItemStandard>
232229
</List>
233230
);
234231

235-
// Check that wrapping attribute is set
236-
cy.get("#wrapping-item")
237-
.should("have.attr", "wrapping");
238-
239232
// Check that wrapping-type attribute is set to Normal
240233
cy.get("#wrapping-item")
241234
.should("have.attr", "wrapping-type", "Normal");
@@ -246,17 +239,13 @@ describe("List - Wrapping Behavior", () => {
246239
.find("ui5-expandable-text")
247240
.should("exist");
248241

249-
// Remove the wrapping attribute from the existing component
242+
// Set wrappingType to None
250243
cy.get("#wrapping-item")
251244
.then($el => {
252-
$el[0].removeAttribute("wrapping");
245+
$el[0].setAttribute("wrapping-type", "None");
253246
});
254247

255-
// Check that wrapping attribute is removed
256-
cy.get("#wrapping-item")
257-
.should("not.have.attr", "wrapping");
258-
259-
// Now check the wrapping-type attribute in a separate command
248+
// Check that wrapping-type attribute is set to None
260249
cy.get("#wrapping-item")
261250
.should("have.attr", "wrapping-type", "None");
262251

packages/main/cypress/specs/List.mobile.cy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("List Mobile Tests", () => {
1111

1212
cy.mount(
1313
<List>
14-
<ListItemStandard id="wrapping-item" wrapping text={longText}></ListItemStandard>
14+
<ListItemStandard id="wrapping-item" wrappingType="Normal" text={longText}></ListItemStandard>
1515
</List>
1616
);
1717

packages/main/src/ListItemStandard.ts

+8-16
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,27 @@ class ListItemStandard extends ListItem implements IAccessibleListItem {
111111
movable = false;
112112

113113
/**
114-
* Defines whether the content of the list item should wrap when it's too long.
115-
* When set to true, the content (title, description) will be wrapped
114+
* Defines if the text of the component should wrap when it's too long.
115+
* When set to "Normal", the content (title, description) will be wrapped
116116
* using the `ui5-expandable-text` component.<br/>
117117
*
118118
* The text can wrap up to 100 characters on small screens (size S) and
119119
* up to 300 characters on larger screens (size M and above). When text exceeds
120120
* these limits, it truncates with an ellipsis followed by a text expansion trigger.
121121
*
122-
* @default false
123-
* @public
124-
* @since 2.9.0
125-
*/
126-
@property({ type: Boolean })
127-
wrapping = false;
128-
129-
/**
130-
* Defines if the text of the component should wrap, they truncate by default.
122+
* Available options are:
123+
* - `None` (default) - The text will truncate with an ellipsis.
124+
* - `Normal` - The text will wrap (without truncation).
131125
*
132-
* **Note:** this property takes affect only if text node is provided to default slot of the component
133126
* @default "None"
134-
* @private
135-
* @since 1.5.0
127+
* @public
128+
* @since 2.9.0
136129
*/
137130
@property()
138131
wrappingType: `${WrappingType}` = "None";
139132

140133
/**
141-
* Defines the text alternative of the component.
134+
* Defines the text alternative of the component.<br/>
142135
* **Note:** If not provided a default text alternative will be set, if present.
143136
* @default undefined
144137
* @public
@@ -173,7 +166,6 @@ class ListItemStandard extends ListItem implements IAccessibleListItem {
173166
super.onBeforeRendering();
174167
this.hasTitle = !!(this.text || this.textContent);
175168
this._hasImage = this.hasImage;
176-
this.wrappingType = this.wrapping ? "Normal" : "None";
177169
}
178170

179171
/**

packages/main/src/ListItemStandardTemplate.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function listItemContent(this: ListItemStandard) {
3131
}
3232

3333
function renderTitle(this: ListItemStandard) {
34-
if (this.wrapping) {
34+
if (this.wrappingType === "Normal") {
3535
return (
3636
<span part="title" class="ui5-li-title">
3737
<ExpandableText
@@ -57,7 +57,7 @@ function renderDescription(this: ListItemStandard) {
5757
return null;
5858
}
5959

60-
if (this.wrapping) {
60+
if (this.wrappingType === "Normal") {
6161
return (
6262
<div class="ui5-li-description-info-wrapper">
6363
<span part="description" class="ui5-li-desc">

packages/main/src/themes/ListItem.css

+22-22
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
object-fit: contain
6868
}
6969

70-
:host(:not([wrapping])[description]) .ui5-li-root {
70+
:host([wrapping-type="None"][description]) .ui5-li-root {
7171
padding: 1rem;
7272
}
7373

@@ -204,70 +204,70 @@
204204
}
205205

206206
/* wrapping */
207-
:host([wrapping][description]),
208-
:host([wrapping][has-title][description]),
209-
:host([wrapping][has-title][image]) {
207+
:host([wrapping-type="Normal"][description]),
208+
:host([wrapping-type="Normal"][has-title][description]),
209+
:host([wrapping-type="Normal"][has-title][image]) {
210210
height: auto;
211211
min-height: 5rem;
212212
}
213213

214-
:host([wrapping][description]) .ui5-li-content,
215-
:host([wrapping][image]) .ui5-li-content {
214+
:host([wrapping-type="Normal"][description]) .ui5-li-content,
215+
:host([wrapping-type="Normal"][image]) .ui5-li-content {
216216
height: auto;
217217
min-height: 3rem;
218218
}
219219

220-
:host([wrapping][has-title][description]) .ui5-li-title {
220+
:host([wrapping-type="Normal"][has-title][description]) .ui5-li-title {
221221
padding-bottom: .75rem;
222222
}
223223

224-
:host([wrapping][additional-text]) .ui5-li-additional-text {
224+
:host([wrapping-type="Normal"][additional-text]) .ui5-li-additional-text {
225225
padding-inline-start: .75rem;
226226
}
227227

228-
:host([wrapping]) .ui5-li-description-info-wrapper {
228+
:host([wrapping-type="Normal"]) .ui5-li-description-info-wrapper {
229229
flex-direction: column;
230230
}
231231

232-
:host([wrapping]) .ui5-li-description-info-wrapper .ui5-li-additional-text {
232+
:host([wrapping-type="Normal"]) .ui5-li-description-info-wrapper .ui5-li-additional-text {
233233
white-space: normal;
234234
}
235235

236-
:host([wrapping]) .ui5-li-title .ui5-li-title-exp-text {
236+
:host([wrapping-type="Normal"]) .ui5-li-title .ui5-li-title-exp-text {
237237
font-size: var(--_ui5_list_item_title_size);
238238
}
239239

240-
:host([wrapping]) .ui5-li-desc .ui5-li-desc-exp-text {
240+
:host([wrapping-type="Normal"]) .ui5-li-desc .ui5-li-desc-exp-text {
241241
color: var(--sapContent_LabelColor);
242242
}
243243

244-
:host([wrapping]) .ui5-li-multisel-cb,
245-
:host([wrapping]) .ui5-li-singlesel-radiobtn {
244+
:host([wrapping-type="Normal"]) .ui5-li-multisel-cb,
245+
:host([wrapping-type="Normal"]) .ui5-li-singlesel-radiobtn {
246246
display: flex;
247247
align-self: flex-start;
248248
}
249249

250-
:host([wrapping][description]) .ui5-li-multisel-cb,
251-
:host([wrapping][description]) .ui5-li-singlesel-radiobtn {
250+
:host([wrapping-type="Normal"][description]) .ui5-li-multisel-cb,
251+
:host([wrapping-type="Normal"][description]) .ui5-li-singlesel-radiobtn {
252252
margin-top: 0;
253253
}
254254

255-
:host([wrapping]) .ui5-li-icon,
256-
:host([wrapping]) .ui5-li-image {
255+
:host([wrapping-type="Normal"]) .ui5-li-icon,
256+
:host([wrapping-type="Normal"]) .ui5-li-image {
257257
display: flex;
258258
align-self: flex-start;
259259
}
260260

261-
:host([wrapping][icon-end]) .ui5-li-icon {
261+
:host([wrapping-type="Normal"][icon-end]) .ui5-li-icon {
262262
margin-top: var(--_ui5_list_item_content_vertical_offset);
263263
}
264264

265-
:host([wrapping]) .ui5-li-image {
265+
:host([wrapping-type="Normal"]) .ui5-li-image {
266266
margin-top: 0;
267267
margin-bottom: 0;
268268
}
269269

270-
:host([wrapping]) .ui5-li-detailbtn,
271-
:host([wrapping]) .ui5-li-deletebtn {
270+
:host([wrapping-type="Normal"]) .ui5-li-detailbtn,
271+
:host([wrapping-type="Normal"]) .ui5-li-deletebtn {
272272
margin-inline-start: .875rem;
273273
}

0 commit comments

Comments
 (0)