Skip to content

Commit c052515

Browse files
committed
fix(menu): new btn structure & loader broke menu
1 parent 5bf36ea commit c052515

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

docs/components/Playground.vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
<script lang="ts" setup>
2-
import { ref } from 'vue'
32
4-
const val = ref('')
5-
const loading = ref(false)
63
</script>
74

85
<template>
9-
<AInput
10-
v-model="val"
11-
class="w-300px m-4"
12-
@input="loading = !loading"
13-
>
14-
<template #prepend-inner>
15-
<ALoadingIcon
16-
icon="i-bx-search"
17-
:loading="loading"
18-
/>
19-
</template>
20-
</AInput>
6+
<ABtn>
7+
Button
8+
</ABtn>
219
</template>

packages/anu-vue/src/components/menu/AMenu.vue

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Middleware, Placement, Strategy } from '@floating-ui/dom'
33
import { autoUpdate, computePosition, flip, shift } from '@floating-ui/dom'
44
import { onClickOutside, useEventListener, useMounted } from '@vueuse/core'
55
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'
77
import { sameWidth as sameWidthMiddleware } from './middlewares'
88
import { useTeleport } from '@/composables/useTeleport'
99
import { useInternalBooleanState } from '@/composables/useInternalBooleanState'
@@ -101,20 +101,20 @@ const calculateFloatingPosition = async () => {
101101
// ℹ️ For this we need need bridge to handle keep menu content open
102102
// offset(6),
103103
104-
sameWidthMiddleware(refFloating.value.$el),
104+
sameWidthMiddleware(refFloating.value),
105105
flip(),
106106
shift({ padding: 10 }),
107107
] as Middleware[]
108-
: props.middleware(refReference.value, refFloating.value.$el)
108+
: props.middleware(refReference.value, refFloating.value)
109109
110110
// 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, {
112112
strategy: props.strategy,
113113
placement: props.placement,
114114
middleware: _middleware,
115115
})
116116
117-
Object.assign(refFloating.value.$el.style, {
117+
Object.assign(refFloating.value.style, {
118118
left: `${x}px`,
119119
top: `${y}px`,
120120
})
@@ -124,15 +124,16 @@ let floatingUiCleanup: Function
124124
125125
onMounted(() => {
126126
const vm = getCurrentInstance()
127-
refReference.value = vm?.proxy?.$el?.parentNode
127+
if (vm?.proxy?.$parent)
128+
refReference.value = vm?.proxy?.$parent.$el
128129
})
129130
130131
// Recalculate position if placement changes at runtime
131132
watch(
132133
[isMounted, () => props.placement],
133134
() => {
134135
nextTick(() => {
135-
floatingUiCleanup = autoUpdate(refReference.value, refFloating.value.$el, calculateFloatingPosition)
136+
floatingUiCleanup = autoUpdate(refReference.value, refFloating.value, calculateFloatingPosition)
136137
})
137138
},
138139
)
@@ -192,18 +193,16 @@ if (props.modelValue === undefined) {
192193
>
193194
<!-- ℹ️ Transition component don't accept null as value of name prop so we need `props.transition || undefined` -->
194195
<Transition :name="props.transition || undefined">
195-
<ACard
196+
<div
196197
v-show="props.modelValue ?? isAlertVisible"
197198
ref="refFloating"
198199
class="a-menu"
199200
:class="[props.strategy === 'fixed' ? 'fixed' : 'absolute']"
200201
>
201-
<slot />
202-
</ACard>
202+
<ACard>
203+
<slot />
204+
</ACard>
205+
</div>
203206
</Transition>
204207
</Teleport>
205208
</template>
206-
207-
<style lang="scss">
208-
209-
</style>

0 commit comments

Comments
 (0)