@@ -3,7 +3,7 @@ import type { Middleware, Placement, Strategy } from '@floating-ui/dom'
3
3
import { autoUpdate , computePosition , flip , shift } from ' @floating-ui/dom'
4
4
import { onClickOutside , useEventListener , useMounted } from ' @vueuse/core'
5
5
import type { PropType } from ' vue'
6
- import { Teleport , Transition , getCurrentInstance , nextTick , onBeforeUnmount , onMounted , ref , watch } from ' vue'
6
+ import { getCurrentInstance , nextTick , onBeforeUnmount , onMounted , ref , watch } from ' vue'
7
7
import { sameWidth as sameWidthMiddleware } from ' ./middlewares'
8
8
import { useTeleport } from ' @/composables/useTeleport'
9
9
import { useInternalBooleanState } from ' @/composables/useInternalBooleanState'
@@ -101,20 +101,20 @@ const calculateFloatingPosition = async () => {
101
101
// ℹ️ For this we need need bridge to handle keep menu content open
102
102
// offset(6),
103
103
104
- sameWidthMiddleware (refFloating .value . $el ),
104
+ sameWidthMiddleware (refFloating .value ),
105
105
flip (),
106
106
shift ({ padding: 10 }),
107
107
] as Middleware []
108
- : props .middleware (refReference .value , refFloating .value . $el )
108
+ : props .middleware (refReference .value , refFloating .value )
109
109
110
110
// Calculate position of floating element
111
- const { x, y } = await computePosition (refReference .value , refFloating .value . $el , {
111
+ const { x, y } = await computePosition (refReference .value , refFloating .value , {
112
112
strategy: props .strategy ,
113
113
placement: props .placement ,
114
114
middleware: _middleware ,
115
115
})
116
116
117
- Object .assign (refFloating .value .$el . style , {
117
+ Object .assign (refFloating .value .style , {
118
118
left: ` ${x }px ` ,
119
119
top: ` ${y }px ` ,
120
120
})
@@ -124,15 +124,16 @@ let floatingUiCleanup: Function
124
124
125
125
onMounted (() => {
126
126
const vm = getCurrentInstance ()
127
- refReference .value = vm ?.proxy ?.$el ?.parentNode
127
+ if (vm ?.proxy ?.$parent )
128
+ refReference .value = vm ?.proxy ?.$parent .$el
128
129
})
129
130
130
131
// Recalculate position if placement changes at runtime
131
132
watch (
132
133
[isMounted , () => props .placement ],
133
134
() => {
134
135
nextTick (() => {
135
- floatingUiCleanup = autoUpdate (refReference .value , refFloating .value . $el , calculateFloatingPosition )
136
+ floatingUiCleanup = autoUpdate (refReference .value , refFloating .value , calculateFloatingPosition )
136
137
})
137
138
},
138
139
)
@@ -192,18 +193,16 @@ if (props.modelValue === undefined) {
192
193
>
193
194
<!-- ℹ️ Transition component don't accept null as value of name prop so we need `props.transition || undefined` -->
194
195
<Transition :name =" props.transition || undefined" >
195
- <ACard
196
+ <div
196
197
v-show =" props.modelValue ?? isAlertVisible"
197
198
ref =" refFloating"
198
199
class =" a-menu"
199
200
:class =" [props.strategy === 'fixed' ? 'fixed' : 'absolute']"
200
201
>
201
- <slot />
202
- </ACard >
202
+ <ACard >
203
+ <slot />
204
+ </ACard >
205
+ </div >
203
206
</Transition >
204
207
</Teleport >
205
208
</template >
206
-
207
- <style lang="scss">
208
-
209
- </style >
0 commit comments