The renamefile function doesn't handle potential errors returned from the xHttp.request call. While the callback renameFileCallback does handle errors and reverts the input field, the renamefile function itself proceeds regardless of success or failure which can lead to unexpected behavior or a confusing UI if the rename fails silently.
function renamefile(id) {
document.getElementById("navn" + id + "form").style.display = "none";
document.getElementById("navn" + id + "div").style.display = "";
var payload = {"name": document.getElementById("navn" + id + "form").firstChild.firstChild.value};
document.getElementById("loading").style.visibility = "";
xHttp.request("/admin/explorer/files/" + id + "/", renameFileCallback, "PUT", payload);
}
The
renamefilefunction doesn't handle potential errors returned from thexHttp.requestcall. While the callbackrenameFileCallbackdoes handle errors and reverts the input field, therenamefilefunction itself proceeds regardless of success or failure which can lead to unexpected behavior or a confusing UI if the rename fails silently.