@@ -94,24 +94,27 @@ const OverflowMenu = React.forwardRef<HTMLDivElement, OverflowMenuProps>(
94
94
const { refs, floatingStyles, placement, middlewareData } = useFloating (
95
95
autoAlign
96
96
? {
97
+ // Computing the position starts with initial positioning
98
+ // via `placement`.
97
99
placement : menuAlignment ,
98
100
99
101
// The floating element is positioned relative to its nearest
100
- // containing block (usually the viewport). It will in many cases also
101
- // “break” the floating element out of a clipping ancestor.
102
+ // containing block (usually the viewport). It will in many cases
103
+ // also “break” the floating element out of a clipping ancestor.
102
104
// https://floating-ui.com/docs/misc#clipping
103
105
strategy : 'fixed' ,
104
106
105
- // Middleware order matters, arrow should be last
107
+ // Middleware are executed as an in-between “middle” step of the
108
+ // initial `placement` computation and eventual return of data for
109
+ // rendering. Each middleware is executed in order.
106
110
middleware : [
107
111
flip ( {
108
- fallbackAxisSideDirection : 'start' ,
109
- fallbackPlacements : [
110
- 'top-start' ,
111
- 'top-end' ,
112
- 'bottom-start' ,
113
- 'bottom-end' ,
114
- ] ,
112
+ // An explicit array of placements to try if the initial
113
+ // `placement` doesn’t fit on the axes in which overflow
114
+ // is checked.
115
+ fallbackPlacements : menuAlignment . includes ( 'bottom' )
116
+ ? [ 'bottom-start' , 'bottom-end' , 'top-start' , 'top-end' ]
117
+ : [ 'top-start' , 'top-end' , 'bottom-start' , 'bottom-end' ] ,
115
118
} ) ,
116
119
] ,
117
120
whileElementsMounted : autoUpdate ,
0 commit comments