Skip to content

Commit

Permalink
fix(ui5-rating-indicator): Aria-readonly attribute is added when Rati…
Browse files Browse the repository at this point in the history
…ngIndicator in not editable (#3219)
  • Loading branch information
niyap authored and ilhan007 committed May 12, 2021
1 parent 54a27ec commit f0d476e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/main/src/RatingIndicator.hbs
Expand Up @@ -6,7 +6,7 @@
aria-valuemax="{{maxValue}}"
aria-orientation="horizontal"
aria-disabled="{{_ariaDisabled}}"
?aria-readonly="{{readOnly}}"
aria-readonly="{{ariaReadonly}}"
tabindex="{{tabIndex}}"
@focusin="{{_onfocusin}}"
@focusout="{{_onfocusout}}"
Expand Down
4 changes: 4 additions & 0 deletions packages/main/src/RatingIndicator.js
Expand Up @@ -294,6 +294,10 @@ class RatingIndicator extends UI5Element {
get _ariaDisabled() {
return this.disabled || undefined;
}

get ariaReadonly() {
return this.readonly ? "true" : undefined;
}
}

RatingIndicator.define();
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test/pages/RatingIndicator.html
Expand Up @@ -47,7 +47,7 @@ <h3>test change event</h3>
<br>

<h3>readonly</h3>
<ui5-rating-indicator value="1" max-value="3" readonly></ui5-rating-indicator>
<ui5-rating-indicator id="rating-indicator-readonly" value="1" max-value="3" readonly></ui5-rating-indicator>
<br>
<br>
<br>
Expand Down
5 changes: 5 additions & 0 deletions packages/main/test/specs/RatingIndicator.spec.js
Expand Up @@ -68,6 +68,8 @@ describe("Rating Indicator general interaction", () => {

it("Tests ACC attrs", () => {
const ratingIndicator = browser.$("#rating-indicator1").shadow$(".ui5-rating-indicator-root");
const ratingIndicatorReadOnly = browser.$("#rating-indicator-readonly").shadow$(".ui5-rating-indicator-root");

const TOOLTIP = "Rating";
const ARIA_LABEL = "Hello World";

Expand All @@ -76,5 +78,8 @@ describe("Rating Indicator general interaction", () => {

assert.strictEqual(ratingIndicator.getAttribute("title"), TOOLTIP,
"The default tooltip is displayed");

assert.notOk(ratingIndicator.getAttribute("aria-readonly"), "The aria-readonly attribute is not presented");
assert.strictEqual(ratingIndicatorReadOnly.getAttribute("aria-readonly"), 'true', "The aria-readonly attribute is presented");
});
});

0 comments on commit f0d476e

Please sign in to comment.