Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/datepicker/js/datepickerDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,11 @@
// Unless the user specifies so, the datepicker should not be a tab stop.
// This is necessary because ngAria might add a tabindex to anything with an ng-model
// (based on whether or not the user has turned that particular feature on/off).
if (!$attrs.tabindex) {
$element.attr('tabindex', '-1');
if ($attrs.tabindex) {
this.ngInputElement.attr('tabindex', $attrs.tabindex);
$attrs.$set('tabindex', null);
} else {
$attrs.$set('tabindex', '-1');
}

$mdTheming($element);
Expand Down
21 changes: 19 additions & 2 deletions src/components/datepicker/js/datepickerDirective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe('md-datepicker', function() {
expect(controller.ngModelCtrl.$modelValue).toEqual(initialDate);
});

it('shoud become touched from bluring closing the pane', function() {
it('should become touched from blurring closing the pane', function() {
populateInputElement('17/1/2015');

controller.openCalendarPane({
Expand All @@ -344,7 +344,7 @@ describe('md-datepicker', function() {
expect(controller.ngModelCtrl.$touched).toBe(true);
});

it('should become touch from bluring the input', function() {
it('should become touch from blurring the input', function() {
populateInputElement('17/1/2015');

var input = angular.element(controller.inputElement);
Expand Down Expand Up @@ -763,4 +763,21 @@ describe('md-datepicker', function() {
expect(pageScope.blurHandler).toHaveBeenCalledTimes(1);
});
});

describe('tabindex behavior', function() {
beforeEach(function() {
ngElement && ngElement.remove();
});

it('should remove the datepicker from the tab order, if no tabindex is specified', function() {
createDatepickerInstance('<md-datepicker ng-model="myDate"></md-datepicker>');
expect(ngElement.attr('tabindex')).toBe('-1');
});

it('should forward the tabindex to the input', function() {
createDatepickerInstance('<md-datepicker ng-model="myDate" tabindex="1"></md-datepicker>');
expect(ngElement.attr('tabindex')).toBeFalsy();
expect(controller.ngInputElement.attr('tabindex')).toBe('1');
});
});
});