@@ -13,7 +13,7 @@ import { IBaseCancelableBrowserEventArgs, PlatformUtil } from '../core/utils';
1313import { IgxToggleModule } from '../directives/toggle/toggle.directive' ;
1414import { IgxIconComponent , IgxIconModule , IgxIconService } from '../icon/public_api' ;
1515import { IgxInputState } from '../input-group/public_api' ;
16- import { AbsoluteScrollStrategy , ConnectedPositioningStrategy } from '../services/public_api' ;
16+ import { AbsoluteScrollStrategy , AutoPositionStrategy , ConnectedPositioningStrategy } from '../services/public_api' ;
1717import { configureTestSuite } from '../test-utils/configure-suite' ;
1818import { UIInteractions , wait } from '../test-utils/ui-interactions.spec' ;
1919import { IgxSimpleComboComponent , IgxSimpleComboModule , ISimpleComboSelectionChangingEventArgs } from './public_api' ;
@@ -811,7 +811,8 @@ describe('IgxSimpleCombo', () => {
811811 declarations : [
812812 IgxSimpleComboSampleComponent ,
813813 IgxComboInContainerTestComponent ,
814- IgxSimpleComboIconTemplatesComponent
814+ IgxSimpleComboIconTemplatesComponent ,
815+ IgxBottomPositionSimpleComboComponent
815816 ] ,
816817 imports : [
817818 IgxSimpleComboModule ,
@@ -1387,6 +1388,52 @@ describe('IgxSimpleCombo', () => {
13871388 clearButton = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_CLEARBUTTON } ` ) ) ;
13881389 expect ( clearButton ) . toBeNull ( ) ;
13891390 } ) ;
1391+
1392+ it ( 'should open the combo to the top when there is no space to open to the bottom' , fakeAsync ( ( ) => {
1393+ fixture = TestBed . createComponent ( IgxBottomPositionSimpleComboComponent ) ;
1394+ fixture . detectChanges ( ) ;
1395+ combo = fixture . componentInstance . combo ;
1396+
1397+ const newSettings = {
1398+ positionStrategy : new AutoPositionStrategy ( ) ,
1399+ scrollStrategy : new AbsoluteScrollStrategy ( )
1400+ } ;
1401+ combo . overlaySettings = newSettings ;
1402+ fixture . detectChanges ( ) ;
1403+
1404+ combo . open ( ) ;
1405+ fixture . detectChanges ( ) ;
1406+ expect ( combo . collapsed ) . toEqual ( false ) ;
1407+ expect ( combo . overlaySettings . positionStrategy . settings . verticalDirection ) . toBe ( - 1 ) ;
1408+
1409+ combo . select ( 'Connecticut' ) ;
1410+ fixture . detectChanges ( ) ;
1411+
1412+ expect ( combo . selection . length ) . toBe ( 1 ) ;
1413+ expect ( combo . selection [ 0 ] ) . toEqual ( 'Connecticut' ) ;
1414+ fixture . detectChanges ( ) ;
1415+
1416+ combo . dropdown . close ( ) ;
1417+ tick ( ) ;
1418+ fixture . detectChanges ( ) ;
1419+ expect ( combo . collapsed ) . toEqual ( true ) ;
1420+
1421+ combo . open ( ) ;
1422+ fixture . detectChanges ( ) ;
1423+ expect ( combo . collapsed ) . toEqual ( false ) ;
1424+ expect ( combo . overlaySettings . positionStrategy . settings . verticalDirection ) . toBe ( - 1 ) ;
1425+
1426+ combo . dropdown . close ( ) ;
1427+ tick ( ) ;
1428+ fixture . detectChanges ( ) ;
1429+ expect ( combo . collapsed ) . toEqual ( true ) ;
1430+
1431+ combo . handleClear ( new MouseEvent ( 'click' ) ) ;
1432+ fixture . detectChanges ( ) ;
1433+ expect ( combo . value ) . toEqual ( '' ) ;
1434+ expect ( combo . collapsed ) . toEqual ( false ) ;
1435+ expect ( combo . overlaySettings . positionStrategy . settings . verticalDirection ) . toBe ( - 1 ) ;
1436+ } ) ) ;
13901437 } ) ;
13911438
13921439 describe ( 'Display density' , ( ) => {
@@ -2198,3 +2245,47 @@ export class IgxSimpleComboBindingDataAfterInitComponent implements AfterViewIni
21982245 } ) ;
21992246 }
22002247}
2248+
2249+ @Component ( {
2250+ template : `
2251+ <div style="display: flex; flex-direction: column; height: 100%; justify-content: flex-end;">
2252+ <igx-simple-combo #combo [data]="items" [displayKey]="'field'" [valueKey]="'field'" [width]="'100%'"
2253+ style="margin-bottom: 60px;">
2254+ </igx-simple-combo>
2255+ </div>`
2256+ } )
2257+ export class IgxBottomPositionSimpleComboComponent {
2258+ @ViewChild ( 'combo' , { read : IgxSimpleComboComponent , static : true } )
2259+ public combo : IgxSimpleComboComponent ;
2260+ public items : any [ ] = [ ] ;
2261+
2262+ constructor ( ) {
2263+ const division = {
2264+ 'New England 01' : [ 'Connecticut' , 'Maine' , 'Massachusetts' ] ,
2265+ 'New England 02' : [ 'New Hampshire' , 'Rhode Island' , 'Vermont' ] ,
2266+ 'Mid-Atlantic' : [ 'New Jersey' , 'New York' , 'Pennsylvania' ] ,
2267+ 'East North Central 02' : [ 'Michigan' , 'Ohio' , 'Wisconsin' ] ,
2268+ 'East North Central 01' : [ 'Illinois' , 'Indiana' ] ,
2269+ 'West North Central 01' : [ 'Missouri' , 'Nebraska' , 'North Dakota' , 'South Dakota' ] ,
2270+ 'West North Central 02' : [ 'Iowa' , 'Kansas' , 'Minnesota' ] ,
2271+ 'South Atlantic 01' : [ 'Delaware' , 'Florida' , 'Georgia' , 'Maryland' ] ,
2272+ 'South Atlantic 02' : [ 'North Carolina' , 'South Carolina' , 'Virginia' ] ,
2273+ 'South Atlantic 03' : [ 'District of Columbia' , 'West Virginia' ] ,
2274+ 'East South Central 01' : [ 'Alabama' , 'Kentucky' ] ,
2275+ 'East South Central 02' : [ 'Mississippi' , 'Tennessee' ] ,
2276+ 'West South Central' : [ 'Arkansas' , 'Louisiana' , 'Oklahome' , 'Texas' ] ,
2277+ Mountain : [ 'Arizona' , 'Colorado' , 'Idaho' , 'Montana' , 'Nevada' , 'New Mexico' , 'Utah' , 'Wyoming' ] ,
2278+ 'Pacific 01' : [ 'Alaska' , 'California' ] ,
2279+ 'Pacific 02' : [ 'Hawaii' , 'Oregon' , 'Washington' ]
2280+ } ;
2281+ const keys = Object . keys ( division ) ;
2282+ for ( const key of keys ) {
2283+ division [ key ] . map ( ( e ) => {
2284+ this . items . push ( {
2285+ field : e ,
2286+ region : key . substring ( 0 , key . length - 3 )
2287+ } ) ;
2288+ } ) ;
2289+ }
2290+ }
2291+ }
0 commit comments