Skip to content

Commit

Permalink
feat(rating): set aria-disabled="true" when readonly
Browse files Browse the repository at this point in the history
Closes #1489
  • Loading branch information
Thibaut Roy authored and pkozlowski-opensource committed Apr 13, 2017
1 parent 88a7f00 commit c89f2c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/rating/rating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ describe('ngb-rating', () => {

expect(rating.attributes['aria-valuetext']).toBe('7 out of 10');
});

it('updates aria-disabled when readonly', () => {
const fixture = createTestComponent('<ngb-rating></ngb-rating>');
let ratingEl = fixture.debugElement.query(By.directive(NgbRating));
fixture.detectChanges();
expect(ratingEl.attributes['aria-disabled']).toBeNull();

let ratingComp = <NgbRating>ratingEl.componentInstance;
ratingComp.readonly = true;
fixture.detectChanges();
expect(ratingEl.attributes['aria-disabled']).toBe('true');
});
});

describe('keyboard support', () => {
Expand Down
1 change: 1 addition & 0 deletions src/rating/rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const NGB_RATING_VALUE_ACCESSOR = {
'[attr.aria-valuemax]': 'max',
'[attr.aria-valuenow]': 'nextRate',
'[attr.aria-valuetext]': 'ariaValueText()',
'[attr.aria-disabled]': 'readonly ? true : null',
'(mouseleave)': 'reset()',
'(keydown)': 'handleKeyDown($event)'
},
Expand Down

0 comments on commit c89f2c4

Please sign in to comment.