fix: error renaming current folder

Massimo Melina committed Sep 21, 2024 at 13:01 UTC 5f8dcc2672d7186a00330dca6c6b155c8be17a8a
1 file changed +2 -1
frontend/src/fileMenu.ts
+2 -1
@@ -150,7 +150,8 @@ async function rename(entry: DirEntry) {
150 const MSG = t`Operation successful`
151 if (uri === location.pathname) //current folder
152 return alertDialog(MSG).then(() =>
153 - getHFS().navigate(uri + '../' + pathEncode(dest) + '/') )
153 + setTimeout(() => // after history.back() issued by closing the dialog
154 + getHFS().navigate(uri + '../' + pathEncode(dest) + '/') ))
155 // update state instead of re-getting the list
156 const newN = n.replace(/(.*?)[^/]+(\/?)$/, (_,before,after) => before + dest + after)
157 const newEntry = new DirEntry(newN, { key: n, ...entry }) // by keeping old key, we avoid unmounting the element, that's causing focus lost