mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
fix: better drag leave handling
This commit is contained in:
parent
eb8b42b1a9
commit
d4be2e3b22
2 changed files with 24 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
v-if="layout === 'main' && initialized"
|
||||
class="absolute md:relative top-0 h-full md:h-screen pt-k-header-height md:pt-0 w-full md:w-auto flex flex-col justify-end"
|
||||
@dragend="onDragEnd"
|
||||
@dragleave="onDragLeave"
|
||||
@dragover="onDragOver"
|
||||
@drop="onDrop"
|
||||
>
|
||||
|
@ -141,6 +142,15 @@ const onDragOver = (e: DragEvent) => {
|
|||
watch(() => queueStore.current, song => (currentSong.value = song))
|
||||
|
||||
const onDragEnd = () => (showDropZone.value = false)
|
||||
|
||||
const onDragLeave = (e: MouseEvent) => {
|
||||
if ((e.currentTarget as Node)?.contains?.(e.relatedTarget as Node)) {
|
||||
return
|
||||
}
|
||||
|
||||
showDropZone.value = false
|
||||
}
|
||||
|
||||
const onDrop = () => (showDropZone.value = false)
|
||||
|
||||
provide(OverlayKey, overlay)
|
||||
|
|
|
@ -91,7 +91,14 @@ const droppable = ref(false)
|
|||
const hasUploadFailures = computed(() => files.value.filter(({ status }) => status === 'Errored').length > 0)
|
||||
|
||||
const onDragEnter = () => (droppable.value = allowsUpload.value)
|
||||
const onDragLeave = () => (droppable.value = false)
|
||||
|
||||
const onDragLeave = (e: MouseEvent) => {
|
||||
if ((e.currentTarget as Node)?.contains?.(e.relatedTarget as Node)) {
|
||||
return
|
||||
}
|
||||
|
||||
droppable.value = false
|
||||
}
|
||||
|
||||
const onFileInputChange = (event: Event) => {
|
||||
const selectedFileList = (event.target as HTMLInputElement).files
|
||||
|
@ -109,3 +116,9 @@ const onDrop = async (event: DragEvent) => {
|
|||
const retryAll = () => uploadService.retryAll()
|
||||
const removeFailedEntries = () => uploadService.removeFailed()
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.droppable {
|
||||
@apply border-2 border-dashed border-white/40 bg-black/20 rounded-3xl;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue