From 89ab4580cd3d0bbdf63e02fbebe2cb3a9f2616dd Mon Sep 17 00:00:00 2001 From: Olivier Leduc Date: Tue, 16 Dec 2014 19:26:13 -0500 Subject: [PATCH] fix(datepicker): fixed shortcut event kill by adding option Added optional `shortcut-propagation` attribute for optionally allowing the keydown event to propagate upwards --- src/datepicker/datepicker.js | 12 ++++++++---- src/datepicker/docs/readme.md | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index b116901bca..137ab1751e 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -14,7 +14,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst startingDay: 0, yearRange: 20, minDate: null, - maxDate: null + maxDate: null, + shortcutPropagation: false }) .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 // Configuration attributes angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle', - 'minMode', 'maxMode', 'showWeeks', 'startingDay', 'yearRange'], function( key, index ) { + 'minMode', 'maxMode', 'showWeeks', 'startingDay', 'yearRange', 'shortcutPropagation'], function( key, index ) { self[key] = angular.isDefined($attrs[key]) ? (index < 8 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : datepickerConfig[key]; }); @@ -175,7 +176,9 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst } evt.preventDefault(); - evt.stopPropagation(); + if(!self.shortcutPropagation){ + evt.stopPropagation(); + } if (key === 'enter' || key === 'space') { if ( self.isDisabled(self.activeDate)) { @@ -201,7 +204,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst scope: { datepickerMode: '=?', dateDisabled: '&', - customClass: '&' + customClass: '&', + shortcutPropagation: '&?' }, require: ['datepicker', '?^ngModel'], controller: 'DatepickerController', diff --git a/src/datepicker/docs/readme.md b/src/datepicker/docs/readme.md index dccb36aff1..baa493d234 100644 --- a/src/datepicker/docs/readme.md +++ b/src/datepicker/docs/readme.md @@ -79,7 +79,11 @@ All settings can be provided as attributes in the `datepicker` or globally confi * `year-range` _(Default: 20)_ : - Number of years displayed in year selection. + Number of years displayed in year selection. + + * `shortcut-propagation` + _(Default: false)_ : + An option to disable or enable shortcut's event propagation. ### Popup Settings ###