@@ -14,7 +14,7 @@ export function computeAutoPlacement(
1414 refRect : Offsets ,
1515 target : HTMLElement ,
1616 host : HTMLElement ,
17- allowedPositions : any [ ] = [ 'top' , 'left ' , 'bottom ' , 'right ' ] ,
17+ allowedPositions : any [ ] = [ 'top' , 'bottom ' , 'right ' , 'left ' ] ,
1818 boundariesElement = 'viewport' ,
1919 padding = 0
2020) {
@@ -52,22 +52,27 @@ export function computeAutoPlacement(
5252 . sort ( ( a , b ) => b . area - a . area ) ;
5353
5454 let filteredAreas : any [ ] = sortedAreas . filter (
55- ( { width, height } ) =>
56- width >= target . clientWidth && height >= target . clientHeight
55+ ( { width, height } ) => {
56+ return width >= target . clientWidth
57+ && height >= target . clientHeight ;
58+ }
5759 ) ;
5860
59- filteredAreas = allowedPositions
60- . reduce ( ( obj , key ) => {
61- return { ...obj , [ key ] : filteredAreas [ key ] } ;
62- } , { } ) ;
61+ filteredAreas = filteredAreas . filter ( ( position : any ) => {
62+ return allowedPositions
63+ . some ( ( allowedPosition : string ) => {
64+ return allowedPosition === position . key ;
65+ } ) ;
66+ } ) ;
6367
6468 const computedPlacement : string = filteredAreas . length > 0
6569 ? filteredAreas [ 0 ] . key
6670 : sortedAreas [ 0 ] . key ;
6771
6872 const variation = placement . split ( ' ' ) [ 1 ] ;
6973
70- target . className = target . className . replace ( / a u t o / g, computedPlacement ) ;
74+ // for tooltip on auto position
75+ target . className = target . className . replace ( / b s - t o o l t i p - a u t o / g, `bs-tooltip-${ computedPlacement } ` ) ;
7176
7277 return computedPlacement + ( variation ? `-${ variation } ` : '' ) ;
7378}
0 commit comments