Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 89ab458

Browse files
oleducwesleycho
authored andcommitted
fix(datepicker): fixed shortcut event kill by adding option
Added optional `shortcut-propagation` attribute for optionally allowing the keydown event to propagate upwards
1 parent 98e2bdf commit 89ab458

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/datepicker/datepicker.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
1414
startingDay: 0,
1515
yearRange: 20,
1616
minDate: null,
17-
maxDate: null
17+
maxDate: null,
18+
shortcutPropagation: false
1819
})
1920

2021
.controller('DatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$timeout', '$log', 'dateFilter', 'datepickerConfig', function($scope, $attrs, $parse, $interpolate, $timeout, $log, dateFilter, datepickerConfig) {
@@ -26,7 +27,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
2627

2728
// Configuration attributes
2829
angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle',
29-
'minMode', 'maxMode', 'showWeeks', 'startingDay', 'yearRange'], function( key, index ) {
30+
'minMode', 'maxMode', 'showWeeks', 'startingDay', 'yearRange', 'shortcutPropagation'], function( key, index ) {
3031
self[key] = angular.isDefined($attrs[key]) ? (index < 8 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : datepickerConfig[key];
3132
});
3233

@@ -175,7 +176,9 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
175176
}
176177

177178
evt.preventDefault();
178-
evt.stopPropagation();
179+
if(!self.shortcutPropagation){
180+
evt.stopPropagation();
181+
}
179182

180183
if (key === 'enter' || key === 'space') {
181184
if ( self.isDisabled(self.activeDate)) {
@@ -201,7 +204,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
201204
scope: {
202205
datepickerMode: '=?',
203206
dateDisabled: '&',
204-
customClass: '&'
207+
customClass: '&',
208+
shortcutPropagation: '&?'
205209
},
206210
require: ['datepicker', '?^ngModel'],
207211
controller: 'DatepickerController',

src/datepicker/docs/readme.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ All settings can be provided as attributes in the `datepicker` or globally confi
7979

8080
* `year-range`
8181
_(Default: 20)_ :
82-
Number of years displayed in year selection.
82+
Number of years displayed in year selection.
83+
84+
* `shortcut-propagation`
85+
_(Default: false)_ :
86+
An option to disable or enable shortcut's event propagation.
8387

8488

8589
### Popup Settings ###

0 commit comments

Comments
 (0)