diff --git a/src/runtime/components/elements/Dropdown.vue b/src/runtime/components/elements/Dropdown.vue index 8c9c7b42d5..f2be13f147 100644 --- a/src/runtime/components/elements/Dropdown.vue +++ b/src/runtime/components/elements/Dropdown.vue @@ -152,9 +152,32 @@ export default defineComponent({ }) const containerStyle = computed(() => { + if (props.mode !== 'hover') { + return {} + } + const offsetDistance = (props.popper as PopperOptions)?.offsetDistance || (ui.value.popper as PopperOptions)?.offsetDistance || 8 + const placement = popper.value.placement?.split('-')[0] + const padding = `${offsetDistance}px` - return props.mode === 'hover' ? { paddingTop: `${offsetDistance}px`, paddingBottom: `${offsetDistance}px` } : {} + if (placement === 'top' || placement === 'bottom') { + return { + paddingTop: padding, + paddingBottom: padding + } + } else if (placement === 'left' || placement === 'right') { + return { + paddingLeft: padding, + paddingRight: padding + } + } else { + return { + paddingTop: padding, + paddingBottom: padding, + paddingLeft: padding, + paddingRight: padding + } + } }) function onMouseOver () {