Skip to content

Commit

Permalink
fix(Popover): handle hover mode with padding like dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Sep 7, 2023
1 parent e2146a5 commit dc951ff
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/runtime/components/overlays/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</slot>
</HPopoverButton>

<div v-if="open" ref="container" :class="[ui.container, ui.width]" @mouseover="onMouseOver">
<div v-if="open" ref="container" :class="[ui.container, ui.width]" :style="containerStyle" @mouseover="onMouseOver">
<Transition appear v-bind="ui.transition">
<HPopoverPanel :class="[ui.base, ui.background, ui.ring, ui.rounded, ui.shadow]" static>
<slot name="panel" :open="open" :close="close" />
Expand Down Expand Up @@ -80,7 +80,7 @@ export default defineComponent({
const ui = computed<Partial<typeof appConfig.ui.popover>>(() => defu({}, props.ui, appConfig.ui.popover))
const popper = computed<PopperOptions>(() => defu({}, props.popper, ui.value.popper as PopperOptions))
const popper = computed<PopperOptions>(() => defu(props.mode === 'hover' ? { offsetDistance: 0 } : {}, props.popper, ui.value.popper as PopperOptions))
const [trigger, container] = usePopper(popper.value)
Expand All @@ -100,6 +100,12 @@ export default defineComponent({
popoverApi.value = popoverProvidesSymbols.length && popoverProvides[popoverProvidesSymbols[0]]
})
const containerStyle = computed(() => {
const offsetDistance = (props.popper as PopperOptions)?.offsetDistance || (ui.value.popper as PopperOptions)?.offsetDistance || 8
return props.mode === 'hover' ? { paddingTop: `${offsetDistance}px`, paddingBottom: `${offsetDistance}px` } : {}
})
function onMouseOver () {
if (props.mode !== 'hover' || !popoverApi.value) {
return
Expand Down Expand Up @@ -146,6 +152,7 @@ export default defineComponent({
popover,
trigger,
container,
containerStyle,
onMouseOver,
onMouseLeave
}
Expand Down

0 comments on commit dc951ff

Please sign in to comment.