Skip to content
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

fix(ui5-li): fix title update when initially empty #2362

Merged
merged 2 commits into from
Oct 28, 2020
Merged
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
4 changes: 1 addition & 3 deletions packages/main/src/StandardListItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

{{#*inline "listItemContent"}}
<div class="ui5-li-title-wrapper">
{{#if textContent.length}}
<span part="title" class="ui5-li-title"><slot></slot></span>
{{/if}}
<span part="title" class="ui5-li-title"><slot></slot></span>
{{#if description}}
<span part="description" class="ui5-li-desc">{{description}}</span>
{{/if}}
Expand Down
11 changes: 11 additions & 0 deletions packages/main/test/pages/List_test_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ <h2 id="testHeader">Test aria</h2>
<ui5-li >item</ui5-li>
</ui5-list>

<ui5-list id="listWithEmptyItem">
<ui5-li id="emptyItem"></ui5-li>
<ui5-li>IPhone 3</ui5-li>
<ui5-li>HP Monitor 24</ui5-li>
</ui5-list>
<ui5-button id="changeEmptyItem">Change empty item text</ui5-button>

<script>
'use strict';

Expand Down Expand Up @@ -199,6 +206,10 @@ <h2 id="testHeader">Test aria</h2>
scrollableContiner.scroll(0, scrollableContiner.scrollHeight);
});

changeEmptyItem.addEventListener("click", function(e) {
emptyItem.textContent = "updated";
});

var loadMoreCounter = 0;
infiniteScrollEx.addEventListener("ui5-loadMore", function(e) {
for(var i = 0; i < 3; i++) {
Expand Down
28 changes: 28 additions & 0 deletions packages/main/test/specs/List.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,32 @@ describe("List Tests", () => {
assert.strictEqual(ulCustomHeader.getAttribute("aria-labelledby"),
null, "aria-labelledby is not present");
});

it("tests title is updated, when initially empty", () => {
const btnChangeEmptyItem = $("#changeEmptyItem");
const emptyItem = $("#emptyItem");
const NEW_TEXT = "updated";
const assignedNodesBefore = browser.execute(() => {
return document.getElementById("emptyItem").shadowRoot.querySelector("slot").assignedNodes().length;
});

// assert default
assert.strictEqual(emptyItem.getProperty("innerHTML"), "",
"The value is empty string");
assert.strictEqual(assignedNodesBefore, 0,
"No slotted elements as no text is present.");

// act
btnChangeEmptyItem.click(); // update the item textContent

const assignedNodesAfter = browser.execute(() => {
return document.getElementById("emptyItem").shadowRoot.querySelector("slot").assignedNodes().length;
});

// assert
assert.strictEqual(emptyItem.getProperty("innerHTML"), NEW_TEXT,
"The value is updated");
assert.strictEqual(assignedNodesAfter, 1,
"The new text is slotted.");
});
});