@@ -17,6 +17,7 @@ import { IgxDropDownItemBaseDirective } from './drop-down-item.base';
1717import { IgxSelectionAPIService } from '../core/selection' ;
1818import { IgxButtonDirective } from '../directives/button/button.directive' ;
1919import { NgFor } from '@angular/common' ;
20+ import { ConnectedPositioningStrategy , HorizontalAlignment , OverlaySettings , VerticalAlignment } from '../services/public_api' ;
2021
2122const CSS_CLASS_DROP_DOWN_BASE = 'igx-drop-down' ;
2223const CSS_CLASS_LIST = 'igx-drop-down__list' ;
@@ -235,6 +236,57 @@ describe('IgxDropDown ', () => {
235236 expect ( dropdown . opening . emit ) . toHaveBeenCalledTimes ( 1 ) ;
236237 expect ( dropdown . opened . emit ) . toHaveBeenCalledTimes ( 1 ) ;
237238 } ) ) ;
239+ it ( 'should use default overlay settings if none are provided' , ( ) => {
240+ const toggle : IgxToggleDirective = ( dropdown as any ) . toggleDirective ;
241+
242+ spyOn ( toggle , 'open' ) . and . callThrough ( ) ;
243+
244+ dropdown . open ( ) ;
245+ fixture . detectChanges ( ) ;
246+ expect ( toggle . open ) . toHaveBeenCalledTimes ( 1 ) ;
247+
248+ const appliedSettings = ( toggle . open as jasmine . Spy ) . calls . mostRecent ( ) . args [ 0 ] ;
249+ expect ( appliedSettings . closeOnOutsideClick ) . toBe ( true ) ;
250+ expect ( appliedSettings . modal ) . toBe ( false ) ;
251+ expect ( appliedSettings . positionStrategy instanceof ConnectedPositioningStrategy ) . toBe ( true ) ;
252+
253+ const positionStrategy = appliedSettings . positionStrategy as ConnectedPositioningStrategy ;
254+ expect ( positionStrategy . settings . horizontalStartPoint ) . toBe ( HorizontalAlignment . Left ) ;
255+ expect ( positionStrategy . settings . verticalStartPoint ) . toBe ( VerticalAlignment . Bottom ) ;
256+ expect ( positionStrategy . settings . horizontalDirection ) . toBe ( HorizontalAlignment . Right ) ;
257+ expect ( positionStrategy . settings . verticalDirection ) . toBe ( VerticalAlignment . Bottom ) ;
258+ } ) ;
259+
260+ it ( 'should apply custom overlay settings if provided' , ( ) => {
261+ const toggle : IgxToggleDirective = ( dropdown as any ) . toggleDirective ;
262+ const customOverlaySettings : OverlaySettings = {
263+ closeOnOutsideClick : false ,
264+ modal : true ,
265+ positionStrategy : new ConnectedPositioningStrategy ( {
266+ horizontalStartPoint : HorizontalAlignment . Right ,
267+ verticalStartPoint : VerticalAlignment . Top ,
268+ horizontalDirection : HorizontalAlignment . Left ,
269+ verticalDirection : VerticalAlignment . Top
270+ } )
271+ } ;
272+
273+ spyOn ( toggle , 'open' ) . and . callThrough ( ) ;
274+
275+ dropdown . open ( customOverlaySettings ) ;
276+ fixture . detectChanges ( ) ;
277+ expect ( toggle . open ) . toHaveBeenCalledTimes ( 1 ) ;
278+
279+ const appliedSettings = ( toggle . open as jasmine . Spy ) . calls . mostRecent ( ) . args [ 0 ] ;
280+ expect ( appliedSettings . closeOnOutsideClick ) . toBe ( customOverlaySettings . closeOnOutsideClick ) ;
281+ expect ( appliedSettings . modal ) . toBe ( customOverlaySettings . modal ) ;
282+ expect ( appliedSettings . positionStrategy instanceof ConnectedPositioningStrategy ) . toBe ( true ) ;
283+
284+ const positionStrategy = appliedSettings . positionStrategy as ConnectedPositioningStrategy ;
285+ expect ( positionStrategy . settings . horizontalStartPoint ) . toBe ( HorizontalAlignment . Right ) ;
286+ expect ( positionStrategy . settings . verticalStartPoint ) . toBe ( VerticalAlignment . Top ) ;
287+ expect ( positionStrategy . settings . horizontalDirection ) . toBe ( HorizontalAlignment . Left ) ;
288+ expect ( positionStrategy . settings . verticalDirection ) . toBe ( VerticalAlignment . Top ) ;
289+ } ) ;
238290 it ( '#2798 - should allow canceling of open/close through opening/closing events' , fakeAsync ( ( ) => {
239291 const toggle : IgxToggleDirective = ( dropdown as any ) . toggleDirective ;
240292 const onOpeningSpy = spyOn ( dropdown . opening , 'emit' ) . and . callThrough ( ) ;
0 commit comments