Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(md-input-group): Disable with ARIA
Browse files Browse the repository at this point in the history
  • Loading branch information
marcysutton authored and Marcy Sutton committed Oct 28, 2014
1 parent d46f74a commit 72bad32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/textField/textField.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function mdInputDirective($mdUtil) {
var isDisabled = $mdUtil.isParentDisabled(element);

element.attr('tabindex', isDisabled ? -1 : 0 );
element.attr('aria-disabled', isDisabled ? 'true' : 'false');
element.attr('type', attr.type || element.parent().attr('type') || "text" );

// When the input value changes, check if it "has" a value, and
Expand Down
15 changes: 13 additions & 2 deletions src/components/textField/textField.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Text Field directives', function() {
email: 'ThomasBurleson@gmail.com',
password: 'your password is incorrect'
}
}
};
});

it('should set input class for focus & blur', function() {
Expand Down Expand Up @@ -200,19 +200,30 @@ describe('Text Field directives', function() {
expect( label.attr('for') ).toBe( "093" );
expect( input.attr('id') ).toBe( label.attr('for') );
});

it('should auto-pair input and label for accessibility.', function() {
var markup ='<md-text-float ' +
' label="{{labels.firstName}}" ' +
' ng-model="user.firstName" >' +
'</md-text-float>';
var el = buildElement( markup, model);
var input = el.find('input');
var label = el.find('label')
var label = el.find('label');

expect( label.attr('for') == "" ).toBe( false );
expect( input.attr('id') ).toBe( label.attr('for') );
});

it('should add an ARIA attribute for disabled inputs', function() {
var markup ='<md-text-float disabled ' +
' label="{{labels.firstName}}" ' +
' ng-model="user.firstName" >' +
'</md-text-float>';
var el = buildElement( markup, model);
var input = el.find('input');

expect( input.attr('aria-disabled') ).toBe( 'true' );
});
});

// ****************************************************************
Expand Down

0 comments on commit 72bad32

Please sign in to comment.