Skip to content

Commit

Permalink
fix(ui5-breadcrumbs): correct missing label for single breadcrumb (#4578
Browse files Browse the repository at this point in the history
)

Add the missing label of breadcrumbs with a single item.

Fixes #4565
  • Loading branch information
kineticjs authored Jan 17, 2022
1 parent fb40514 commit 42254d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/main/src/Breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class Breadcrumbs extends UI5Element {

_hasVisibleContent(item) {
// the check is not complete but may be extended in the future if needed to cover
// cases becides the standard (UX-recommended) ones
// cases besides the standard (UX-recommended) ones
return item.innerText || Array.from(item.children).some(child => !child.hidden);
}

Expand All @@ -454,7 +454,7 @@ class Breadcrumbs extends UI5Element {

get _currentLocationText() {
const items = this.getSlottedNodes("items");
if (this._endsWithCurrentLocationLabel && items.length > 1) {
if (this._endsWithCurrentLocationLabel && items.length) {
const item = items[items.length - 1];
if (this._isItemVisible(item)) {
return item.innerText;
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test/pages/Breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h2>Empty Breadcrumbs</h2>

<div class="breadcrumbs9auto">
<h2>Empty Breadcrumbs with Location only</h2>
<ui5-breadcrumbs>
<ui5-breadcrumbs id="breadcrumbsWithSingleItem">
<ui5-breadcrumbs-item>Location</ui5-breadcrumbs-item>
</ui5-breadcrumbs>
</div>
Expand Down
8 changes: 8 additions & 0 deletions packages/main/test/specs/Breadcrumbs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ describe("Breadcrumbs general interaction", () => {
assert.strictEqual(await breadcrumbs.getProperty("_overflowSize"), expectedCountItemsInOverflowAfter, "a link is added to the overflow");
});

it("standard breadcrumb with single item shows location", async () => {
const breadcrumbs = await browser.$("#breadcrumbsWithSingleItem"),
label = (await breadcrumbs.shadow$("ui5-label"));

// Check
assert.strictEqual(await label.getText(), "Location", "label is displayed");
});

it("opens upon space", async () => {
await browser.url(`http://localhost:${PORT}/test-resources/pages/Breadcrumbs.html`);

Expand Down
2 changes: 1 addition & 1 deletion packages/theming/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rZnyMTmoc2CFM82C+7zGHcw3GGY=
CQhk8M6oN0XzkZBkgImthR2kdTs=

0 comments on commit 42254d8

Please sign in to comment.