Skip to content

Commit cfd4fa3

Browse files
authored
feat(framework): implement stabledomref functionality (#1868)
1 parent 97c299d commit cfd4fa3

File tree

7 files changed

+44
-6
lines changed

7 files changed

+44
-6
lines changed

packages/base/src/UI5Element.js

+9
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,15 @@ class UI5Element extends HTMLElement {
589589
}
590590
}
591591

592+
/**
593+
* Use this method in order to get a reference to element in the shadow root of a web component
594+
* @public
595+
* @param {String} refName Defines the name of the stable DOM ref
596+
*/
597+
getStableDomRef(refName) {
598+
return this.getDomRef().querySelector(`[data-ui5-stable=${refName}]`);
599+
}
600+
592601
/**
593602
* Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
594603
* @public

packages/fiori/src/ShellBar.hbs

+14-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
@keydown="{{_logoKeydown}}"
2020
@keyup="{{_logoKeyup}}"
2121
tabindex="0"
22+
data-ui5-stable="logo"
2223
>
2324
<slot name="logo"></slot>
2425
</span>
@@ -62,7 +63,9 @@
6263
title="{{_copilotText}}"
6364
@keydown="{{_coPilotKeydown}}"
6465
@keyup="{{_coPilotKeyup}}"
65-
?active="{{coPilotActive}}">
66+
?active="{{coPilotActive}}"
67+
data-ui5-stable="copilot"
68+
>
6669
{{> coPilot}}
6770
</div>
6871
{{else}}
@@ -107,6 +110,7 @@
107110
data-count="{{this.count}}"
108111
data-ui5-notification-count="{{../notificationCount}}"
109112
data-ui5-external-action-item-id="{{this.refItemid}}"
113+
data-ui5-stable="{{stableDomRef}}"
110114
@click={{this.press}}
111115
></ui5-button>
112116
{{/each}}
@@ -123,6 +127,7 @@
123127
aria-label="{{_notificationsText}}"
124128
title="{{_notificationsText}}"
125129
._buttonAccInfo="{{accInfo.notifications}}"
130+
data-ui5-stable="notifications"
126131
></ui5-button>
127132
{{/if}}
128133

@@ -135,6 +140,7 @@
135140
aria-label="{{_overflowText}}"
136141
title="{{_overflowText}}"
137142
._buttonAccInfo="{{accInfo.overflow}}"
143+
data-ui5-stable="overflow"
138144
></ui5-button>
139145

140146
{{#if hasProfile}}
@@ -146,10 +152,12 @@
146152
aria-label="{{_profileText}}"
147153
title="{{_profileText}}"
148154
._buttonAccInfo="{{accInfo.profile}}"
149-
class="ui5-shellbar-button ui5-shellbar-image-button">
150-
<slot
151-
name="profile"
152-
></slot>
155+
class="ui5-shellbar-button ui5-shellbar-image-button"
156+
data-ui5-stable="profile"
157+
>
158+
<slot
159+
name="profile"
160+
></slot>
153161
</ui5-button>
154162
{{/if}}
155163

@@ -164,6 +172,7 @@
164172
aria-label="{{_productsText}}"
165173
title="{{_productsText}}"
166174
._buttonAccInfo="{{accInfo.products}}"
175+
data-ui5-stable="product-switch"
167176
></ui5-button>
168177
{{/if}}
169178
</div>

packages/fiori/src/ShellBar.js

+1
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ class ShellBar extends UI5Element {
761761
press: this._handleCustomActionPress.bind(this),
762762
custom: true,
763763
title: item.title,
764+
stableDomRef: item.stableDomRef,
764765
};
765766
}),
766767
{

packages/fiori/src/ShellBarItem.js

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ const metadata = {
4040
count: {
4141
type: String,
4242
},
43+
44+
/**
45+
* Defines the stable selector that you can use via getStableDomRef method.
46+
* @public
47+
* @since 1.0.0-rc.8
48+
*/
49+
stableDomRef: {
50+
type: String,
51+
},
4352
},
4453

4554
events: /** @lends sap.ui.webcomponents.fiori.ShellBarItem.prototype */ {

packages/main/src/Tab.js

+9
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ const metadata = {
102102
defaultValue: SemanticColor.Default,
103103
},
104104

105+
/**
106+
* Defines the stable selector that you can use via getStableDomRef method.
107+
* @public
108+
* @since 1.0.0-rc.8
109+
*/
110+
stableDomRef: {
111+
type: String,
112+
},
113+
105114
/**
106115
* Specifies if the <code>ui5-tab</code> is selected.
107116
*

packages/main/src/TabInStrip.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
?aria-disabled="{{this.effectiveDisabled}}"
1010
?disabled="{{this.effectiveDisabled}}"
1111
aria-labelledby="{{this.ariaLabelledBy}}"
12+
data-ui5-stable="{{this.stableDomRef}}"
1213
>
1314

1415
{{#if this.icon}}

packages/main/test/pages/TabContainer.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h1 class="header-title">ui5-tabcontainer</h1>
5555
<section>
5656
<h2>Tab Container</h2>
5757
<ui5-tabcontainer id="tabContainer1" fixed collapsed show-overflow>
58-
<ui5-tab text="Products" additional-text="125">
58+
<ui5-tab stable-dom-ref="products-ref" text="Products" additional-text="125">
5959
</ui5-tab>
6060
<ui5-tab-separator></ui5-tab-separator>
6161
<ui5-tab icon="sap-icon://menu2" text="Laptops" semantic-color="Positive" additional-text="25">

0 commit comments

Comments
 (0)