Skip to content

Commit ae7b395

Browse files
feat(ui5-segmentedbutton): implement accessibility spec (#1475)
* feat(ui5-segmentedbutton): implement acc spec * fixed styling * fixed comments * changes related to spec changing
1 parent df19ede commit ae7b395

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

packages/main/src/SegmentedButton.hbs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@click="{{_onclick}}"
33
@focusin="{{_onfocusin}}"
44
class="ui5-segmentedbutton-root"
5+
role="group"
6+
aria-roledescription="{{ariaDescription}}"
57
>
68
<slot></slot>
79
</div>

packages/main/src/SegmentedButton.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation.js";
33
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
4+
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
45
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
6+
import { SEGMENTEDBUTTON_ARIA_DESCRIPTION } from "./generated/i18n/i18n-defaults.js";
57

68
// Template
79
import SegmentedButtonTemplate from "./generated/templates/SegmentedButtonTemplate.lit.js";
@@ -90,6 +92,10 @@ class SegmentedButton extends UI5Element {
9092
return SegmentedButtonCss;
9193
}
9294

95+
static async onDefine() {
96+
await fetchI18nBundle("@ui5/webcomponents");
97+
}
98+
9399
constructor() {
94100
super();
95101
this.initItemNavigation();
@@ -99,6 +105,7 @@ class SegmentedButton extends UI5Element {
99105
this.hasPreviouslyFocusedItem = false;
100106

101107
this._handleResizeBound = this._handleResize.bind(this);
108+
this.i18nBundle = getI18nBundle("@ui5/webcomponents");
102109
}
103110

104111
onEnterDOM() {
@@ -201,6 +208,10 @@ class SegmentedButton extends UI5Element {
201208
get selectedButton() {
202209
return this._selectedButton;
203210
}
211+
212+
get ariaDescription() {
213+
return this.i18nBundle.getText(SEGMENTEDBUTTON_ARIA_DESCRIPTION);
214+
}
204215
}
205216

206217
SegmentedButton.define();

packages/main/src/i18n/messagebundle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ MULTIINPUT_SHOW_MORE_TOKENS={0} More
247247
#XTOL: Tooltip for panel expand title
248248
PANEL_ICON=Expand/Collapse
249249

250+
#XACT: ARIA description for the segmented button
251+
SEGMENTEDBUTTON_ARIA_DESCRIPTION=Segmented button
252+
250253
#XACT: ARIA announcement for the switch on
251254
SWITCH_ON=On
252255

0 commit comments

Comments
 (0)