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 Aug 2, 2023
1 parent b696b15 commit 9e5b8cc
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

1 comment on commit 9e5b8cc

@vercel
Copy link

@vercel vercel bot commented on 9e5b8cc Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-git-dev-nuxtlabs.vercel.app
ui-nuxtlabs.vercel.app
ui.nuxtlabs.com

Please sign in to comment.