Skip to content

Commit d23330a

Browse files
authored
fix(ui5-shellbar): preserve insertion order for ShellBarItems (#13590)
ShellBarItems with icon="feedback" or icon="sys-help" were always displayed at the end of the actions area, ignoring their position in the DOM. Items now appear in the same order they are declared. Remove PREDEFINED_PLACE_ITEMS, sortItems(), and all call sites, passing this.items directly instead. JIRA: BGSOFUIPIRIN-7070
1 parent 9124a8e commit d23330a

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

packages/fiori/cypress/specs/ShellBar.cy.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import sysHelp from "@ui5/webcomponents-icons/dist/sys-help.js";
77
import da from "@ui5/webcomponents-icons/dist/da.js";
88
import "@ui5/webcomponents-icons/dist/accept.js";
99
import "@ui5/webcomponents-icons/dist/alert.js";
10+
import "@ui5/webcomponents-icons/dist/feedback.js";
1011
import "@ui5/webcomponents-icons/dist/disconnected.js";
1112
import "@ui5/webcomponents-icons/dist/incoming-call.js";
1213
import Input from "@ui5/webcomponents/dist/Input.js";
@@ -1813,6 +1814,23 @@ describe("Component Behavior", () => {
18131814
cy.get("@alertClick")
18141815
.should("have.been.calledOnce");
18151816
});
1817+
1818+
it("renders items in insertion order regardless of icon name", () => {
1819+
cy.mount(
1820+
<ShellBar>
1821+
<ShellBarItem id="item-feedback" icon="feedback" text="Feedback" stable-dom-ref="item-feedback" />
1822+
<ShellBarItem id="item-accept" icon="accept" text="Accept" stable-dom-ref="item-accept" />
1823+
<ShellBarItem id="item-alert" icon="alert" text="Alert" stable-dom-ref="item-alert" />
1824+
</ShellBar>
1825+
);
1826+
1827+
cy.get("[ui5-shellbar]").shadow().find(".ui5-shellbar-custom-item").then($items => {
1828+
// feedback was inserted first, so its wrapper must be the first custom item in the DOM
1829+
expect($items[0].getAttribute("data-ui5-stable")).to.equal("item-feedback");
1830+
expect($items[1].getAttribute("data-ui5-stable")).to.equal("item-accept");
1831+
expect($items[2].getAttribute("data-ui5-stable")).to.equal("item-alert");
1832+
});
1833+
});
18161834
});
18171835

18181836
it("Test disabled slotted button does not show hover styles", () => {

packages/fiori/src/ShellBar.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ import type ListItemBase from "@ui5/webcomponents/dist/ListItemBase.js";
7171

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

74-
// actions always visible in lean mode, order is important
75-
const PREDEFINED_PLACE_ITEMS = ["feedback", "sys-help"];
76-
7774
const ShellBarActions = {
7875
Search: "search",
7976
Profile: "profile",
@@ -767,7 +764,7 @@ class ShellBar extends UI5Element {
767764
const result = this.overflow.updateOverflow({
768765
actions: this.actions,
769766
content: this.sortContent(this.content),
770-
customItems: this.sortItems(this.items),
767+
customItems: this.items,
771768
hiddenItemsIds: this.hiddenItemsIds,
772769
showSearchField: this.enabledFeatures.search && this.showSearchField,
773770
overflowOuter: this.overflowOuter!,
@@ -865,7 +862,7 @@ class ShellBar extends UI5Element {
865862
get overflowItems() {
866863
return this.overflow.getOverflowItems({
867864
actions: this.actions,
868-
customItems: this.sortItems(this.items),
865+
customItems: this.items,
869866
hiddenItemsIds: this.hiddenItemsIds,
870867
});
871868
}
@@ -1060,14 +1057,6 @@ class ShellBar extends UI5Element {
10601057

10611058
/* =================== Items Management =================== */
10621059

1063-
sortItems(items: readonly ShellBarItem[]) {
1064-
return items.toSorted((a, b) => {
1065-
const aIndex = PREDEFINED_PLACE_ITEMS.indexOf(a.icon || "");
1066-
const bIndex = PREDEFINED_PLACE_ITEMS.indexOf(b.icon || "");
1067-
return aIndex - bIndex;
1068-
});
1069-
}
1070-
10711060
/* =================== Accessibility =================== */
10721061

10731062
get actionsAccessibilityInfo(): ShellBarAccessibilityInfo {

packages/fiori/src/ShellBarTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export default function ShellBarTemplate(this: ShellBar) {
153153
)}
154154

155155
{/* Custom Items */}
156-
{this.sortItems(this.items).map(item => (
156+
{this.items.map(item => (
157157
<div
158158
key={item._id}
159159
class={{

0 commit comments

Comments
 (0)