Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const positionLabels: Record<string, string> = {
bottom: 'Bottom',
left: 'Left',
}
const positionDropdownPlacement: Record<string, 'top' | 'bottom' | 'left' | 'right'> = {
top: 'bottom',
bottom: 'top',
left: 'right',
right: 'left',
}

function switchPosition(pos: 'top' | 'right' | 'bottom' | 'left') {
store.position = pos
Expand Down Expand Up @@ -74,6 +80,7 @@ function togglePositionDropdown() {
setEdgePositionDropdown({
el: positionButton.value,
gap: 6,
placement: positionDropdownPlacement[store.position],
content: () => h('div', { class: 'flex flex-col gap-0.5 min-w-28' }, positions.map(pos =>
h('button', {
class: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ const FloatingPopoverComponent = defineComponent({

const vw = window.innerWidth
const vh = window.innerHeight
if (rect.left < DETECT_MARGIN)
if (props.item?.placement)
align = props.item.placement
else if (rect.left < DETECT_MARGIN)
align = 'right'
else if (rect.left + rect.width > vw - DETECT_MARGIN)
align = 'left'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface FloatingPopoverProps {
el: HTMLElement
content: string | (() => VNode | undefined)
gap?: number
placement?: 'top' | 'bottom' | 'left' | 'right'
}

const tooltip = shallowRef<FloatingPopoverProps | null>(null)
Expand Down
Loading