@@ -1352,6 +1352,46 @@ describe('MatAutocomplete', () => {
1352
1352
. toEqual ( Math . floor ( panelBottom ) , `Expected panel to fall back to above position.` ) ;
1353
1353
} ) ) ;
1354
1354
1355
+ it ( 'should allow the panel to expand when the number of results increases' , fakeAsync ( ( ) => {
1356
+ let fixture = createComponent ( SimpleAutocomplete ) ;
1357
+ fixture . detectChanges ( ) ;
1358
+
1359
+ let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
1360
+ let inputReference = fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) . nativeElement ;
1361
+
1362
+ // Push the element down so it has a little bit of space, but not enough to render.
1363
+ inputReference . style . bottom = '10px' ;
1364
+ inputReference . style . position = 'fixed' ;
1365
+
1366
+ // Type enough to only show one option.
1367
+ typeInElement ( 'California' , inputEl ) ;
1368
+ fixture . detectChanges ( ) ;
1369
+ tick ( ) ;
1370
+
1371
+ fixture . componentInstance . trigger . openPanel ( ) ;
1372
+ fixture . detectChanges ( ) ;
1373
+ zone . simulateZoneExit ( ) ;
1374
+
1375
+ let panel = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) ! ;
1376
+ let initialPanelHeight = panel . getBoundingClientRect ( ) . height ;
1377
+
1378
+ fixture . componentInstance . trigger . closePanel ( ) ;
1379
+ fixture . detectChanges ( ) ;
1380
+
1381
+ // Change the text so we get more than one result.
1382
+ typeInElement ( 'C' , inputEl ) ;
1383
+ fixture . detectChanges ( ) ;
1384
+ tick ( ) ;
1385
+
1386
+ fixture . componentInstance . trigger . openPanel ( ) ;
1387
+ fixture . detectChanges ( ) ;
1388
+ zone . simulateZoneExit ( ) ;
1389
+
1390
+ panel = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) ! ;
1391
+
1392
+ expect ( panel . getBoundingClientRect ( ) . height ) . toBeGreaterThan ( initialPanelHeight ) ;
1393
+ } ) ) ;
1394
+
1355
1395
it ( 'should align panel properly when filtering in "above" position' , fakeAsync ( ( ) => {
1356
1396
let fixture = createComponent ( SimpleAutocomplete ) ;
1357
1397
fixture . detectChanges ( ) ;
0 commit comments