-
Notifications
You must be signed in to change notification settings - Fork 275
feat(ui5-shellbar): implement accessibility spec #1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
d06724e
6ecacc7
07a9621
a72e3d6
849a5a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,23 @@ import StandardListItem from "@ui5/webcomponents/dist/StandardListItem.js"; | |
import List from "@ui5/webcomponents/dist/List.js"; | ||
import Popover from "@ui5/webcomponents/dist/Popover.js"; | ||
import Button from "@ui5/webcomponents/dist/Button.js"; | ||
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js"; | ||
import "@ui5/webcomponents-icons/dist/icons/search.js"; | ||
import "@ui5/webcomponents-icons/dist/icons/bell.js"; | ||
import "@ui5/webcomponents-icons/dist/icons/overflow.js"; | ||
import "@ui5/webcomponents-icons/dist/icons/grid.js"; | ||
|
||
import { | ||
SHELLBAR_LABEL, | ||
SHELLBAR_LOGO, | ||
SHELLBAR_COPILOT, | ||
SHELLBAR_NOTIFICATIONS, | ||
SHELLBAR_PROFILE, | ||
SHELLBAR_PRODUCTS, | ||
SHELLBAR_SEARCH, | ||
SHELLBAR_OVERFLOW, | ||
} from "./generated/i18n/i18n-defaults.js"; | ||
|
||
// Templates | ||
import ShellBarTemplate from "./generated/templates/ShellBarTemplate.lit.js"; | ||
import ShellBarPopoverTemplate from "./generated/templates/ShellBarPopoverTemplate.lit.js"; | ||
|
@@ -144,6 +156,14 @@ const metadata = { | |
type: String, | ||
multiple: true, | ||
}, | ||
_menuPopoverExpanded: { | ||
type: Boolean, | ||
noAttribute: true, | ||
}, | ||
_overflowPopoverExpanded: { | ||
type: Boolean, | ||
noAttribute: true, | ||
}, | ||
}, | ||
managedSlots: true, | ||
slots: /** @lends sap.ui.webcomponents.fiori.ShellBar.prototype */ { | ||
|
@@ -389,7 +409,7 @@ class ShellBar extends UI5Element { | |
press: async () => { | ||
this._updateClonedMenuItems(); | ||
|
||
if (this.menuItems.length) { | ||
if (this.hasMenuItems) { | ||
this.updateStaticAreaItemContentDensity(); | ||
const menuPopover = await this._getMenuPopover(); | ||
menuPopover.openBy(this.shadowRoot.querySelector(".ui5-shellbar-menu-button")); | ||
|
@@ -406,6 +426,8 @@ class ShellBar extends UI5Element { | |
this.overflowPopover.close(); | ||
this._overflowActions(); | ||
}; | ||
|
||
this.i18nBundle = getI18nBundle("@ui5/webcomponents"); | ||
} | ||
|
||
_menuItemPress(event) { | ||
|
@@ -414,12 +436,45 @@ class ShellBar extends UI5Element { | |
}, true); | ||
} | ||
|
||
_logoPress(event) { | ||
_logoPress() { | ||
this.fireEvent("logoClick", { | ||
targetRef: this.shadowRoot.querySelector(".ui5-shellbar-logo"), | ||
}); | ||
} | ||
|
||
_menuPopoverBeforeOpen() { | ||
this._menuPopoverExpanded = true; | ||
} | ||
|
||
_menuPopoverAfterClose() { | ||
this._menuPopoverExpanded = false; | ||
} | ||
|
||
_overflowPopoverBeforeOpen() { | ||
this._overflowPopoverExpanded = true; | ||
} | ||
|
||
_overflowPopoverAfterClose() { | ||
this._overflowPopoverExpanded = false; | ||
} | ||
|
||
_logoKeyup(event) { | ||
if (isSpace(event)) { | ||
this._logoPress(); | ||
} | ||
} | ||
|
||
_logoKeydown(event) { | ||
if (isSpace(event)) { | ||
event.preventDefault(); | ||
return; | ||
} | ||
|
||
if (isEnter(event)) { | ||
this._logoPress(); | ||
} | ||
} | ||
|
||
_fireCoPilotClick() { | ||
this.fireEvent("coPilotClick", { | ||
targetRef: this.shadowRoot.querySelector(".ui5-shellbar-coPilot"), | ||
|
@@ -792,7 +847,7 @@ class ShellBar extends UI5Element { | |
"ui5-shellbar-with-searchfield": this.searchField.length, | ||
}, | ||
button: { | ||
"ui5-shellbar-menu-button--interactive": !!this.menuItems.length, | ||
"ui5-shellbar-menu-button--interactive": this.hasMenuItems, | ||
"ui5-shellbar-menu-button": true, | ||
}, | ||
items: { | ||
|
@@ -840,11 +895,19 @@ class ShellBar extends UI5Element { | |
} | ||
|
||
get interactiveLogo() { | ||
return this.breakpointSize === "S"; | ||
return this.breakpointSize === "S" && this.hasMenuItems; | ||
} | ||
|
||
get hasNonInteractiveLogo() { | ||
return this.logo && !this.interactiveLogo; | ||
} | ||
|
||
get hasInteractiveLogo() { | ||
return this.logo && this.interactiveLogo; | ||
} | ||
|
||
get showArrowDown() { | ||
return this.primaryTitle || (this.logo && this.interactiveLogo); | ||
return this.primaryTitle || this.hasInteractvieLogo; | ||
} | ||
|
||
get popoverHorizontalAlign() { | ||
|
@@ -863,12 +926,80 @@ class ShellBar extends UI5Element { | |
return !!this.profile.length; | ||
} | ||
|
||
get hasMenuItems() { | ||
return this.menuItems.length > 0; | ||
} | ||
|
||
get menuBtnHasPopup() { | ||
return this.hasMenuItems ? true : undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "true" seems more appropriate, but if it works this way it's ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be cast to string in when it is used in hbs |
||
} | ||
|
||
get menuBtnTabindex() { | ||
return this.menuItems.length > 0 ? "0" : "-1"; | ||
return this.hasMenuItems ? "0" : "-1"; | ||
} | ||
|
||
get menuPopoverExpanded() { | ||
return this.hasMenuItems ? this._menuPopoverExpanded : undefined; | ||
} | ||
|
||
get _shellbarText() { | ||
return this.i18nBundle.getText(SHELLBAR_LABEL); | ||
} | ||
|
||
get _logoText() { | ||
return this.i18nBundle.getText(SHELLBAR_LOGO); | ||
} | ||
|
||
get _copilotText() { | ||
return this.i18nBundle.getText(SHELLBAR_COPILOT); | ||
} | ||
|
||
get _notificationsText() { | ||
return this.i18nBundle.getText(SHELLBAR_NOTIFICATIONS, this.notificationCount); | ||
} | ||
|
||
get _profileText() { | ||
return this.i18nBundle.getText(SHELLBAR_PROFILE); | ||
} | ||
|
||
get _productsText() { | ||
return this.i18nBundle.getText(SHELLBAR_PRODUCTS); | ||
} | ||
|
||
get _searchText() { | ||
return this.i18nBundle.getText(SHELLBAR_SEARCH); | ||
} | ||
|
||
get _overflowText() { | ||
return this.i18nBundle.getText(SHELLBAR_OVERFLOW); | ||
} | ||
|
||
get accInfo() { | ||
return { | ||
notifications: { | ||
"title": this._notificationsText, | ||
}, | ||
profile: { | ||
"title": this._profileText, | ||
}, | ||
products: { | ||
"title": this._productsText, | ||
}, | ||
search: { | ||
"ariaExpanded": this.showSearchField, | ||
"title": this._searchText, | ||
}, | ||
overflow: { | ||
"title": this._overflowText, | ||
"ariaHaspopup": true, | ||
"ariaExpanded": this._overflowPopoverExpanded, | ||
}, | ||
}; | ||
} | ||
|
||
static async onDefine() { | ||
await Promise.all([ | ||
fetchI18nBundle("@ui5/webcomponents-fiori"), | ||
Button.define(), | ||
List.define(), | ||
Popover.define(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,28 @@ UPLOADCOLLECTION_NO_DATA_DESCRIPTION=Drop files to upload, or use the Upload but | |
UPLOADCOLLECTION_DRAG_FILE_INDICATOR=Drag files here | ||
|
||
#XMSG: Message text indicating where to drop file and upload | ||
UPLOADCOLLECTION_DROP_FILE_INDICATOR=Drop files to upload | ||
UPLOADCOLLECTION_DROP_FILE_INDICATOR=Drop files to upload | ||
|
||
#XACT: ARIA announcement for the logo button | ||
nnaydenow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SHELLBAR_LABEL = Logo | ||
nnaydenow marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why label and then logo. The two texts seem the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot to change the value of parameter. It should be Shell Bar and it will be used as value for aria-label attribute of the Shell Bar, |
||
|
||
#XACT: ARIA announcement for the logo button | ||
SHELLBAR_LOGO = Logo | ||
|
||
#XACT: ARIA announcement for the CoPilot button | ||
SHELLBAR_COPILOT = CoPilot | ||
|
||
#XACT: ARIA announcement for the nofications button | ||
nnaydenow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SHELLBAR_NOTIFICATIONS = {0} Notications | ||
nnaydenow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#XACT: ARIA announcement for the profile button | ||
SHELLBAR_PROFILE = Profile | ||
|
||
#XACT: ARIA announcement for the products button | ||
SHELLBAR_PRODUCTS = Products | ||
|
||
#XACT: ARIA announcement for the search button | ||
SHELLBAR_SEARCH = Search | ||
|
||
#XACT: ARIA announcement for the more button | ||
SHELLBAR_OVERFLOW = More |
Uh oh!
There was an error while loading. Please reload this page.