File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -1396,6 +1396,38 @@ describe("Component Behavior", () => {
13961396 . find ( "button" )
13971397 . should ( "have.attr" , "aria-haspopup" , NOTIFICATIONS_BTN_ARIA_HASPOPUP ) ;
13981398 } ) ;
1399+
1400+ it ( "tests imageBtnText logical OR fallback - uses default i18n text when no custom text provided" , ( ) => {
1401+ cy . mount (
1402+ < ShellBar >
1403+ < img src = "https://upload.wikimedia.org/wikipedia/commons/5/59/SAP_2011_logo.svg" slot = "profile" />
1404+ </ ShellBar >
1405+ ) ;
1406+
1407+ // When no aria-label is provided, imageBtnText should fallback to SHELLBAR_IMAGE_BTN i18n text
1408+ cy . get ( "[ui5-shellbar]" ) . should ( "have.prop" , "imageBtnText" , "User Menu" ) ;
1409+ } ) ;
1410+
1411+ it ( "tests SHELLBAR_IMAGE_BTN i18n key is properly used as fallback" , ( ) => {
1412+ cy . mount (
1413+ < ShellBar >
1414+ < Avatar slot = "profile" icon = "customer" />
1415+ </ ShellBar >
1416+ ) ;
1417+
1418+ // Verify that the exact i18n text from SHELLBAR_IMAGE_BTN is used
1419+ cy . get ( "[ui5-shellbar]" ) . then ( ( $shellbar ) => {
1420+ const imageBtnText = $shellbar . prop ( "imageBtnText" ) ;
1421+ // This should be exactly "User Menu" from messagebundle.properties SHELLBAR_IMAGE_BTN
1422+ expect ( imageBtnText ) . to . equal ( "User Menu" ) ;
1423+ } ) ;
1424+
1425+ // Verify the profile button actually uses this text in its aria-label
1426+ cy . get ( "[ui5-shellbar]" )
1427+ . shadow ( )
1428+ . find ( ".ui5-shellbar-image-button" )
1429+ . should ( "have.attr" , "aria-label" , "User Menu" ) ;
1430+ } ) ;
13991431 } ) ;
14001432
14011433 describe ( "ui5-shellbar menu" , ( ) => {
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ import {
7272 SHELLBAR_SEARCHFIELD_DESCRIPTION ,
7373 SHELLBAR_SEARCH_BTN_OPEN ,
7474 SHELLBAR_PRODUCT_SWITCH_BTN ,
75+ SHELLBAR_IMAGE_BTN ,
7576} from "./generated/i18n/i18n-defaults.js" ;
7677
7778type ShellBarLogoAccessibilityAttributes = {
@@ -1552,7 +1553,7 @@ class ShellBar extends UI5Element {
15521553 }
15531554
15541555 get imageBtnText ( ) {
1555- return getEffectiveAriaLabelText ( this ) ;
1556+ return getEffectiveAriaLabelText ( this ) || ShellBar . i18nBundle . getText ( SHELLBAR_IMAGE_BTN ) ;
15561557 }
15571558
15581559 get _shellbarText ( ) {
Original file line number Diff line number Diff line change @@ -191,6 +191,9 @@ SHELLBAR_SEARCH = Search
191191# XACT: ARIA announcement for the search field
192192SHELLBAR_SEARCH_FIELD = Search Field
193193
194+ # XACT: ARIA announcement for the image button
195+ SHELLBAR_IMAGE_BTN = User Menu
196+
194197# XACT: ARIA announcement for the search button
195198SHELLBAR_SEARCH_BTN_OPEN = Open Search
196199
You can’t perform that action at this time.
0 commit comments