@@ -333,14 +333,14 @@ describe('md-date-picker', function() {
333
333
// Expect that the pane is on-screen.
334
334
var paneRect = controller . calendarPane . getBoundingClientRect ( ) ;
335
335
expect ( paneRect . bottom ) . toBeLessThan ( window . innerHeight + 1 ) ;
336
- document . body . removeChild ( superLongElement ) ;
337
336
338
337
document . body . removeChild ( element ) ;
338
+ document . body . removeChild ( superLongElement ) ;
339
339
} ) ;
340
340
341
341
it ( 'should adjust the pane position if it would go off-screen if body is not scrollable' ,
342
342
function ( ) {
343
- // Make the body super huge and scroll halfway down.
343
+ // Make the body super huge and scroll down a bunch .
344
344
var body = document . body ;
345
345
var superLongElement = document . createElement ( 'div' ) ;
346
346
superLongElement . style . height = '10000px' ;
@@ -365,13 +365,43 @@ describe('md-date-picker', function() {
365
365
// Expect that the pane is on-screen.
366
366
var paneRect = controller . calendarPane . getBoundingClientRect ( ) ;
367
367
expect ( paneRect . bottom ) . toBeLessThan ( window . innerHeight + 1 ) ;
368
- body . removeChild ( superLongElement ) ;
369
368
370
369
// Restore body to pre-test state.
371
370
body . removeChild ( element ) ;
371
+ body . removeChild ( superLongElement ) ;
372
372
body . style . overflow = previousBodyOverflow ;
373
373
} ) ;
374
374
375
+ it ( 'should keep the calendar pane in the right place with body scrolling disabled' , function ( ) {
376
+ // Make the body super huge and scroll down a bunch.
377
+ var body = document . body ;
378
+ var superLongElement = document . createElement ( 'div' ) ;
379
+ superLongElement . style . height = '10000px' ;
380
+ superLongElement . style . width = '1px' ;
381
+ body . appendChild ( superLongElement ) ;
382
+ body . scrollTop = 700 ;
383
+
384
+ // Absolutely position the picker such that the pane position doesn't need to be adjusted.
385
+ // (1/10 of the way down the screen).
386
+ element . style . position = 'absolute' ;
387
+ element . style . top = ( document . body . scrollTop + ( window . innerHeight * 0.10 ) ) + 'px' ;
388
+ element . style . left = '0' ;
389
+ body . appendChild ( element ) ;
390
+
391
+ // Open the pane.
392
+ element . querySelector ( 'md-button' ) . click ( ) ;
393
+ $timeout . flush ( ) ;
394
+
395
+ // Expect that the calendar pane is in the same position as the inline datepicker.
396
+ var paneRect = controller . calendarPane . getBoundingClientRect ( ) ;
397
+ var triggerRect = controller . inputContainer . getBoundingClientRect ( ) ;
398
+ expect ( paneRect . top ) . toBe ( triggerRect . top ) ;
399
+
400
+ // Restore body to pre-test state.
401
+ body . removeChild ( superLongElement ) ;
402
+ body . removeChild ( element ) ;
403
+ } ) ;
404
+
375
405
it ( 'should shink the calendar pane when it would otherwise not fit on the screen' , function ( ) {
376
406
// Fake the window being very narrow so that the calendar pane won't fit on-screen.
377
407
controller . $window = { innerWidth : 200 , innherHeight : 800 } ;
0 commit comments