Skip to content

Commit c814db1

Browse files
[backport core/1.33] Fix job details popover sticking after cancel/delete (#7256)
Backport of #6930 to `core/1.33` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7256-backport-core-1-33-Fix-job-details-popover-sticking-after-cancel-delete-2c46d73d3650819ba0ffccb9e41e8783) by [Unito](https://www.unito.io) Co-authored-by: Benjamin Lu <benjaminlu1107@gmail.com>
1 parent 87f8de7 commit c814db1

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

src/components/queue/job/JobGroupsList.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
</template>
3737

3838
<script setup lang="ts">
39-
import { ref } from 'vue'
39+
import { onBeforeUnmount, ref, watch } from 'vue'
4040
4141
import QueueJobItem from '@/components/queue/job/QueueJobItem.vue'
4242
import type { JobGroup, JobListItem } from '@/composables/queue/useJobList'
4343
44-
defineProps<{ displayedJobGroups: JobGroup[] }>()
44+
const props = defineProps<{ displayedJobGroups: JobGroup[] }>()
4545
4646
const emit = defineEmits<{
4747
(e: 'cancelItem', item: JobListItem): void
@@ -89,4 +89,26 @@ const onDetailsLeave = (jobId: string) => {
8989
hideTimer.value = null
9090
}, 150)
9191
}
92+
93+
const resetActiveDetails = () => {
94+
clearHideTimer()
95+
clearShowTimer()
96+
activeDetailsId.value = null
97+
}
98+
99+
watch(
100+
() => props.displayedJobGroups,
101+
(groups) => {
102+
const activeId = activeDetailsId.value
103+
if (!activeId) return
104+
105+
const hasActiveJob = groups.some((group) =>
106+
group.items.some((item) => item.id === activeId)
107+
)
108+
109+
if (!hasActiveJob) resetActiveDetails()
110+
}
111+
)
112+
113+
onBeforeUnmount(resetActiveDetails)
92114
</script>

src/components/queue/job/QueueJobItem.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
size="sm"
136136
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
137137
:aria-label="t('g.delete')"
138-
@click.stop="emit('delete')"
138+
@click.stop="onDeleteClick"
139139
>
140140
<i class="icon-[lucide--trash-2] size-4" />
141141
</IconButton>
@@ -150,7 +150,7 @@
150150
size="sm"
151151
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
152152
:aria-label="t('g.cancel')"
153-
@click.stop="emit('cancel')"
153+
@click.stop="onCancelClick"
154154
>
155155
<i class="icon-[lucide--x] size-4" />
156156
</IconButton>
@@ -190,7 +190,7 @@
190190
size="sm"
191191
class="size-6 transform gap-1 rounded bg-destructive-background text-text-primary transition duration-150 ease-in-out hover:-translate-y-px hover:bg-destructive-background-hover hover:opacity-95"
192192
:aria-label="t('g.cancel')"
193-
@click.stop="emit('cancel')"
193+
@click.stop="onCancelClick"
194194
>
195195
<i class="icon-[lucide--x] size-4" />
196196
</IconButton>
@@ -355,6 +355,18 @@ const computedShowClear = computed(() => {
355355
return props.state !== 'completed'
356356
})
357357
358+
const emitDetailsLeave = () => emit('details-leave', props.jobId)
359+
360+
const onCancelClick = () => {
361+
emitDetailsLeave()
362+
emit('cancel')
363+
}
364+
365+
const onDeleteClick = () => {
366+
emitDetailsLeave()
367+
emit('delete')
368+
}
369+
358370
const onContextMenu = (event: MouseEvent) => {
359371
const shouldShowMenu = props.showMenu !== undefined ? props.showMenu : true
360372
if (shouldShowMenu) emit('menu', event)

0 commit comments

Comments
 (0)