Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix: Screen reader will now properly prompt errors for text inputs. C…
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Jul 12, 2019
2 parents e24da36 + 4b027a6 commit 3a164b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/labeledinput/labeledinputview.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export default class LabeledInputView extends View {
bind.if( 'errorText', 'ck-labeled-input__status_error' ),
bind.if( '_statusText', 'ck-hidden', value => !value )
],
id: statusUid
id: statusUid,
role: bind.if( 'errorText', 'alert' )
},
children: [
{
Expand Down
4 changes: 4 additions & 0 deletions tests/labeledinput/labeledinputview.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ describe( 'LabeledInputView', () => {
view.errorText = '';
expect( statusElement.classList.contains( 'ck-hidden' ) ).to.be.true;
expect( statusElement.classList.contains( 'ck-labeled-input__status_error' ) ).to.be.false;
expect( statusElement.hasAttribute( 'role' ) ).to.be.false;
expect( statusElement.innerHTML ).to.equal( '' );

view.errorText = 'foo';
expect( statusElement.classList.contains( 'ck-hidden' ) ).to.be.false;
expect( statusElement.classList.contains( 'ck-labeled-input__status_error' ) ).to.be.true;
expect( statusElement.getAttribute( 'role' ) ).to.equal( 'alert' );
expect( statusElement.innerHTML ).to.equal( 'foo' );
} );

Expand All @@ -107,11 +109,13 @@ describe( 'LabeledInputView', () => {
view.infoText = '';
expect( statusElement.classList.contains( 'ck-hidden' ) ).to.be.true;
expect( statusElement.classList.contains( 'ck-labeled-input__status_error' ) ).to.be.false;
expect( statusElement.hasAttribute( 'role' ) ).to.be.false;
expect( statusElement.innerHTML ).to.equal( '' );

view.infoText = 'foo';
expect( statusElement.classList.contains( 'ck-hidden' ) ).to.be.false;
expect( statusElement.classList.contains( 'ck-labeled-input__status_error' ) ).to.be.false;
expect( statusElement.hasAttribute( 'role' ) ).to.be.false;
expect( statusElement.innerHTML ).to.equal( 'foo' );
} );
} );
Expand Down

0 comments on commit 3a164b7

Please sign in to comment.