Skip to content
Open
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
18 changes: 18 additions & 0 deletions packages/fiori/cypress/specs/ShellBar.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import sysHelp from "@ui5/webcomponents-icons/dist/sys-help.js";
import da from "@ui5/webcomponents-icons/dist/da.js";
import "@ui5/webcomponents-icons/dist/accept.js";
import "@ui5/webcomponents-icons/dist/alert.js";
import "@ui5/webcomponents-icons/dist/feedback.js";
import "@ui5/webcomponents-icons/dist/disconnected.js";
import "@ui5/webcomponents-icons/dist/incoming-call.js";
import Input from "@ui5/webcomponents/dist/Input.js";
Expand Down Expand Up @@ -1813,6 +1814,23 @@ describe("Component Behavior", () => {
cy.get("@alertClick")
.should("have.been.calledOnce");
});

it("renders items in insertion order regardless of icon name", () => {
cy.mount(
<ShellBar>
<ShellBarItem id="item-feedback" icon="feedback" text="Feedback" stable-dom-ref="item-feedback" />
<ShellBarItem id="item-accept" icon="accept" text="Accept" stable-dom-ref="item-accept" />
<ShellBarItem id="item-alert" icon="alert" text="Alert" stable-dom-ref="item-alert" />
</ShellBar>
);

cy.get("[ui5-shellbar]").shadow().find(".ui5-shellbar-custom-item").then($items => {
// feedback was inserted first, so its wrapper must be the first custom item in the DOM
expect($items[0].getAttribute("data-ui5-stable")).to.equal("item-feedback");
expect($items[1].getAttribute("data-ui5-stable")).to.equal("item-accept");
expect($items[2].getAttribute("data-ui5-stable")).to.equal("item-alert");
});
});
});

it("Test disabled slotted button does not show hover styles", () => {
Expand Down
15 changes: 2 additions & 13 deletions packages/fiori/src/ShellBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ import type ListItemBase from "@ui5/webcomponents/dist/ListItemBase.js";

type ShellBarBreakpoint = "S" | "M" | "L" | "XL" | "XXL";

// actions always visible in lean mode, order is important
const PREDEFINED_PLACE_ITEMS = ["feedback", "sys-help"];

const ShellBarActions = {
Search: "search",
Profile: "profile",
Expand Down Expand Up @@ -767,7 +764,7 @@ class ShellBar extends UI5Element {
const result = this.overflow.updateOverflow({
actions: this.actions,
content: this.sortContent(this.content),
customItems: this.sortItems(this.items),
customItems: this.items,
hiddenItemsIds: this.hiddenItemsIds,
showSearchField: this.enabledFeatures.search && this.showSearchField,
overflowOuter: this.overflowOuter!,
Expand Down Expand Up @@ -865,7 +862,7 @@ class ShellBar extends UI5Element {
get overflowItems() {
return this.overflow.getOverflowItems({
actions: this.actions,
customItems: this.sortItems(this.items),
customItems: this.items,
hiddenItemsIds: this.hiddenItemsIds,
});
}
Expand Down Expand Up @@ -1060,14 +1057,6 @@ class ShellBar extends UI5Element {

/* =================== Items Management =================== */

sortItems(items: readonly ShellBarItem[]) {
return items.toSorted((a, b) => {
const aIndex = PREDEFINED_PLACE_ITEMS.indexOf(a.icon || "");
const bIndex = PREDEFINED_PLACE_ITEMS.indexOf(b.icon || "");
return aIndex - bIndex;
});
}

/* =================== Accessibility =================== */

get actionsAccessibilityInfo(): ShellBarAccessibilityInfo {
Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/src/ShellBarTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
)}

{/* Custom Items */}
{this.sortItems(this.items).map(item => (
{this.items.map(item => (
<div
key={item._id}
class={{
Expand Down Expand Up @@ -233,7 +233,7 @@
opener="ui5-shellbar-overflow-button"
placement="Bottom"
hideArrow={true}
horizontalAlign={this.popoverHorizontalAlign} // TODO: add test

Check warning on line 236 in packages/fiori/src/ShellBarTemplate.tsx

View workflow job for this annotation

GitHub Actions / check

Unexpected 'todo' comment: 'TODO: add test'
>
<List separators="None" onClick={this.handleOverflowItemClick}>
{this.overflowItems.map(item => {
Expand Down
Loading