Skip to content

Commit 850fa42

Browse files
fix(ui5-slider, ui5-range-slider): correct f2 announcement (#11476)
1 parent 1da7437 commit 850fa42

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

packages/main/cypress/specs/Slider.cy.tsx

+24
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,27 @@ describe("General interactions", () => {
2424
});
2525
});
2626
});
27+
28+
describe("Accessibility", () => {
29+
it("aria-keyshortcuts should not be set on regular slider", () => {
30+
cy.mount(
31+
<Slider min={0} max={20}></Slider>
32+
);
33+
34+
cy.get("[ui5-slider]")
35+
.shadow()
36+
.find(".ui5-slider-handle")
37+
.should("not.have.attr", "aria-keyshortcuts");
38+
});
39+
40+
it("aria-keyshortcuts should be set on slider with editable tooltips", () => {
41+
cy.mount(
42+
<Slider editableTooltip={true} min={0} max={20}></Slider>
43+
);
44+
45+
cy.get("[ui5-slider]")
46+
.shadow()
47+
.find(".ui5-slider-handle")
48+
.should("have.attr", "aria-keyshortcuts");
49+
});
50+
});

packages/main/src/RangeSliderTemplate.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function handles(this: RangeSlider) {
6060
aria-labelledby={this._ariaLabelledByStartHandleText}
6161
aria-disabled={this._ariaDisabled}
6262
aria-describedby={this._ariaDescribedByHandleText}
63-
aria-keyshortcuts="F2"
63+
aria-keyshortcuts={this._ariaKeyshortcuts}
6464
>
6565
<Icon name={directionArrows}
6666
mode="Decorative"

packages/main/src/SliderBase.ts

+4
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,10 @@ abstract class SliderBase extends UI5Element {
786786
return this.disabled ? -1 : 0;
787787
}
788788

789+
get _ariaKeyshortcuts() {
790+
return this.editableTooltip ? "F2" : undefined;
791+
}
792+
789793
get _ariaDescribedByHandleText() {
790794
return this.editableTooltip ? "ui5-slider-InputDesc" : undefined;
791795
}

packages/main/src/SliderTemplate.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function handles(this: Slider) {
4444
aria-valuenow={this.value}
4545
aria-labelledby={this._ariaLabelledByHandleText}
4646
aria-disabled={this._ariaDisabled}
47-
aria-keyshortcuts="F2"
47+
aria-keyshortcuts={this._ariaKeyshortcuts}
4848
aria-describedby={this._ariaDescribedByHandleText}
4949
data-sap-focus-ref
5050
part="handle"

0 commit comments

Comments
 (0)