This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
src/components/datepicker/js Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 197
197
198
198
var boundKeyHandler = angular . bind ( this , this . handleKeyEvent ) ;
199
199
200
+
201
+
202
+ // If use the md-calendar directly in the body without datepicker,
203
+ // handleKeyEvent will disable other inputs on the page.
204
+ // So only apply the handleKeyEvent on the body when the md-calendar inside datepicker,
205
+ // otherwise apply on the calendar element only.
206
+
207
+ var handleKeyElement ;
208
+ if ( $element . parent ( ) . hasClass ( 'md-datepicker-calendar' ) ) {
209
+ handleKeyElement = angular . element ( document . body ) ;
210
+ } else {
211
+ handleKeyElement = $element ;
212
+ }
213
+
200
214
// Bind the keydown handler to the body, in order to handle cases where the focused
201
215
// element gets removed from the DOM and stops propagating click events.
202
- angular . element ( document . body ) . on ( 'keydown' , boundKeyHandler ) ;
216
+ handleKeyElement . on ( 'keydown' , boundKeyHandler ) ;
203
217
204
218
$scope . $on ( '$destroy' , function ( ) {
205
- angular . element ( document . body ) . off ( 'keydown' , boundKeyHandler ) ;
219
+ handleKeyElement . off ( 'keydown' , boundKeyHandler ) ;
206
220
} ) ;
207
221
208
222
if ( this . minDate && this . minDate > $mdDateLocale . firstRenderableDate ) {
Original file line number Diff line number Diff line change @@ -114,7 +114,8 @@ describe('md-calendar', function() {
114
114
function dispatchKeyEvent ( keyCode , opt_modifiers ) {
115
115
var mod = opt_modifiers || { } ;
116
116
117
- angular . element ( document . body ) . triggerHandler ( {
117
+
118
+ angular . element ( element ) . triggerHandler ( {
118
119
type : 'keydown' ,
119
120
keyCode : keyCode ,
120
121
which : keyCode ,
You can’t perform that action at this time.
0 commit comments