Skip to content

Commit

Permalink
Remove custom keyboard mode in datepicker (#13644)
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes authored and Tim Roes committed Aug 23, 2017
1 parent fd084ae commit 59aa497
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/ui/public/angular-bootstrap/datepicker/datepicker.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div ng-switch="datepickerMode" role="application" ng-keydown="keydown($event)">
<div ng-switch="datepickerMode" role="application">
<daypicker ng-switch-when="day" tabindex="0"></daypicker>
<monthpicker ng-switch-when="month" tabindex="0"></monthpicker>
<yearpicker ng-switch-when="year" tabindex="0"></yearpicker>
</div>
</div>
27 changes: 2 additions & 25 deletions src/ui/public/angular-bootstrap/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
} else {
self.activeDate = date;
$scope.datepickerMode = self.modes[ self.modes.indexOf( $scope.datepickerMode ) - 1 ];
focusElement();
}
};

Expand All @@ -137,6 +138,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
}

$scope.datepickerMode = self.modes[ self.modes.indexOf( $scope.datepickerMode ) + direction ];
focusElement();
};

// Key event mapper
Expand All @@ -150,31 +152,6 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst

// Listen for focus requests from popup directive
$scope.$on('datepicker.focus', focusElement);

$scope.keydown = function( evt ) {
var key = $scope.keys[evt.which];

if ( !key || evt.shiftKey || evt.altKey ) {
return;
}

evt.preventDefault();
evt.stopPropagation();

if (key === 'enter' || key === 'space') {
if ( self.isDisabled(self.activeDate)) {
return; // do nothing
}
$scope.select(self.activeDate);
focusElement();
} else if (evt.ctrlKey && (key === 'up' || key === 'down')) {
$scope.toggleMode(key === 'up' ? 1 : -1);
focusElement();
} else {
self.handleKeyDown(key, evt);
self.refreshView();
}
};
}])

.directive( 'datepicker', function () {
Expand Down

0 comments on commit 59aa497

Please sign in to comment.