Add leave confirmation to upload widget

This commit is contained in:
2023-03-27 16:00:13 +02:00
parent 7fb34666b0
commit e5fa6cfc88

View File

@@ -96,8 +96,19 @@ const finish_upload = (e) => {
start_upload() start_upload()
} }
const leave_confirmation = e => {
if (state === "uploading") {
e.preventDefault()
e.returnValue = "If you close this page your files will stop uploading. Do you want to continue?"
return e.returnValue
} else {
return null
}
}
</script> </script>
<svelte:window on:beforeunload={leave_confirmation} />
<input <input
bind:this={file_input_field} bind:this={file_input_field}
on:change={file_input_change} on:change={file_input_change}