Skip to content

Commit

Permalink
fix(kpop): not enterable (#2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopoldthecoder authored Oct 30, 2024
1 parent 3da6d13 commit 9bc3d3a
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions src/components/KPop/KPop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
</slot>
</div>

<Transition
:key="popoverKey"
name="kongponents-fade-transition"
>
<Transition name="kongponents-fade-transition">
<div
v-show="isVisible"
ref="popoverElement"
Expand Down Expand Up @@ -86,9 +83,9 @@
</template>

<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue'
import { ref, onMounted, onBeforeUnmount, computed, watch } from 'vue'
import type { PropType } from 'vue'
import { useFloating, autoUpdate, autoPlacement, flip, shift, size } from '@floating-ui/vue'
import { useFloating, autoUpdate, autoPlacement, flip, shift } from '@floating-ui/vue'
import type { PopPlacements, PopTrigger } from '@/types'
import { PopPlacementsArray, PopTriggerArray } from '@/types'
import useUtilities from '@/composables/useUtilities'
Expand Down Expand Up @@ -171,7 +168,6 @@ const kPopoverElement = ref<HTMLElement | null>(null)
const triggerWrapperElement = ref<HTMLElement | null>(null)
const popoverElement = ref<HTMLElement | null>(null)
const isVisible = ref<boolean>(false)
const popoverKey = ref<number>(0)
const popoverTrigger = computed((): HTMLElement | null => triggerWrapperElement.value && triggerWrapperElement.value?.children[0] ? triggerWrapperElement.value?.children[0] as HTMLElement : null)
Expand Down Expand Up @@ -207,10 +203,6 @@ const showPopover = async () => {
clearTimeout(timer.value)
}
if (props.placement !== 'auto') {
popoverKey.value++
await nextTick() // wait for the Transition to update to ensure the animation works as expected
}
startFloatingUpdates()
isVisible.value = true
}
Expand Down Expand Up @@ -271,22 +263,6 @@ const { floatingStyles, placement: calculatedPlacement, update: updatePosition }
middleware: [
shift(), // Shifts the floating element to keep it in view.
flip(), // Changes the placement of the floating element to keep it in view.
/**
* ! Needs to be placed after flip middleware
* Need to use the size middleware to set the max-width and max-height of the popover
* So that it can prefer the original position as much as possible
* Docs: https://floating-ui.com/docs/size#using-with-flip
*/
size({
apply({ elements, availableWidth, availableHeight }) {
requestAnimationFrame(() => {
Object.assign(elements.floating.style, {
maxWidth: `${availableWidth}px`,
maxHeight: `${availableHeight}px`,
})
})
},
}),
],
}),
strategy: 'fixed',
Expand Down

0 comments on commit 9bc3d3a

Please sign in to comment.