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

Commit

Permalink
fix(datepicker): fixed shortcut event kill by adding option
Browse files Browse the repository at this point in the history
Added optional `shortcut-propagation` attribute for optionally allowing the keydown event to propagate upwards
  • Loading branch information
oleduc authored and wesleycho committed Mar 24, 2015
1 parent 98e2bdf commit 89ab458
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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];
});

Expand Down Expand Up @@ -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)) {
Expand All @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion src/datepicker/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down

0 comments on commit 89ab458

Please sign in to comment.