Skip to content

Commit 91b6aab

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 596b330 + 015a5cf commit 91b6aab

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

supervisor/shared/web_workflow/static/directory.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,17 @@ async function mkdir(e) {
191191
}
192192
}
193193

194+
const beforeUnloadHandler = function(event){
195+
// Recommended
196+
event.preventDefault();
197+
198+
// Included for legacy support, e.g. Chrome/Edge < 119
199+
event.returnValue = true;
200+
}
201+
194202
async function upload(e) {
203+
const upload_path = current_path;
204+
window.addEventListener("beforeunload", beforeUnloadHandler);
195205
set_upload_enabled(false);
196206
let progress = document.querySelector("#progress");
197207
let made_dirs = new Set();
@@ -213,7 +223,7 @@ async function upload(e) {
213223
made_dirs.add(parent_dir);
214224
}
215225
}
216-
let file_path = new URL("/fs" + current_path + file_name, url_base);
226+
let file_path = new URL("/fs" + upload_path + file_name, url_base);
217227
const response = await fetch(file_path,
218228
{
219229
method: "PUT",
@@ -242,6 +252,7 @@ async function upload(e) {
242252
files.value = "";
243253
dirs.value = "";
244254
set_upload_enabled(true);
255+
window.removeEventListener("beforeunload", beforeUnloadHandler);
245256
}
246257

247258
async function del(e) {

0 commit comments

Comments
 (0)