1
1
import React , { useState } from 'react'
2
2
import produce , { Draft } from 'immer'
3
3
import { usePopper } from 'react-popper'
4
- import { Placement } from '@popperjs/core'
5
- import { Options } from '@popperjs/core/lib/modifiers/offset'
4
+ import { Placement , PositioningStrategy } from '@popperjs/core'
5
+ import { Options as OffetOptions } from '@popperjs/core/lib/modifiers/offset'
6
6
7
7
import getEventPath , { handleRefs , getDirection } from './utils'
8
8
export interface MenuItem {
@@ -46,7 +46,6 @@ interface NestedMenuState {
46
46
isOpen : boolean
47
47
currentPath : string [ ]
48
48
currentPathItems : MenuItem [ ]
49
- placement ?: Placement
50
49
}
51
50
52
51
/**
@@ -84,7 +83,8 @@ interface NestedMenuProps {
84
83
isOpen ?: boolean
85
84
defaultOpenPath ?: string [ ]
86
85
placement ?: Placement
87
- offset ?: Options [ 'offset' ]
86
+ offset ?: OffetOptions [ 'offset' ]
87
+ strategy ?: PositioningStrategy
88
88
}
89
89
90
90
// interface HitAreaProps {
@@ -102,13 +102,13 @@ export const useNestedMenu = ({
102
102
defaultOpenPath = [ ] ,
103
103
placement,
104
104
offset,
105
+ strategy,
105
106
} : NestedMenuProps ) => {
106
107
const [ state , dispatch ] = React . useReducer ( reducer , {
107
108
items,
108
109
isOpen,
109
110
currentPath : defaultOpenPath ,
110
111
currentPathItems : [ ] ,
111
- placement,
112
112
} )
113
113
114
114
const globalClickHandler = React . useCallback (
@@ -266,7 +266,8 @@ export const useNestedMenu = ({
266
266
const menuRef = React . useRef < HTMLElement > ( )
267
267
268
268
const { styles, attributes } = usePopper ( toggleButtonRef . current , popperElement , {
269
- placement : 'right-start' ,
269
+ placement : placement ,
270
+ strategy : strategy ,
270
271
modifiers : [
271
272
{
272
273
name : 'offset' ,
0 commit comments