Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Use bottom placement for flow run scatter plot popover #1559

Closed
wants to merge 3 commits into from
Closed
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
64 changes: 11 additions & 53 deletions src/components/FlowRunPopOver.vue
Original file line number Diff line number Diff line change
@@ -1,71 +1,24 @@
<template>
<PPopOver ref="popover" class="flow-run-pop-over">
<template #target>
<div ref="trigger" class="flow-run-pop-over__trigger" @mouseover="open" />
<PPopOver class="flow-run-pop-over" group="flow-run-pop-over" auto-close :placement="placement">
<template #target="{ open }">
<div class="flow-run-pop-over__trigger" @mouseover="open" />
</template>

<div ref="content" class="flow-run-pop-over__content">
<div class="flow-run-pop-over__content">
<FlowRunPopoverContent :flow-run-id="flowRunId" />
</div>
</PPopOver>
</template>

<script lang="ts" setup>
import { PPopOver } from '@prefecthq/prefect-design'
import { onMounted, onUnmounted, ref } from 'vue'
import { PPopOver, positions } from '@prefecthq/prefect-design'
import FlowRunPopoverContent from '@/components/FlowRunPopOverContent.vue'

defineProps<{
flowRunId: string,
}>()

const popover = ref<InstanceType<typeof PPopOver>>()
const trigger = ref<HTMLDivElement>()
const content = ref<HTMLDivElement>()

onMounted(() => {
document.addEventListener('mouseover', mouseover)
document.addEventListener('click', click)
})

onUnmounted(() => {
document.removeEventListener('mouseover', mouseover)
document.removeEventListener('click', click)
})

function open(): void {
if (popover.value) {
popover.value.open()
}
}

function click(event: MouseEvent): void {
const target = event.target as HTMLElement

if (!popover.value || !content.value) {
return
}

if (content.value.contains(target)) {
return
}

popover.value.close()
}

function mouseover(event: MouseEvent): void {
const target = event.target as HTMLElement

if (!popover.value || !trigger.value) {
return
}

if (trigger.value.contains(target) || !target.classList.contains('flow-run-pop-over__trigger')) {
return
}

popover.value.close()
}
const placement = [positions.top, positions.bottom, positions.right, positions.left]
</script>

<style>
Expand All @@ -84,4 +37,9 @@
w-full
h-full
}

.flow-run-pop-over__content { @apply
p-2
pointer-events-none
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this prevent interacting with the contents of the popover? So I wouldn't be able to hover a point and then go to the run associated with it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm I feel like you are correct, I wanted to add some spacing between the trigger and the content but not have it as part of the interaction. But I think you're right this will cascade to the content itself. I'll double check

}
</style>