fix(panel): keep the import password field hidden until a file is chosen
test / test (push) Has been cancelled

The field was revealed whenever no file was selected, so the import card
opened asking for a password it had no use for yet. Hide it in that case
too; an unrecognised extension still reveals it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
mixeme
2026-08-07 22:11:55 +03:00
parent 2c5c21f212
commit db56fcc3f3
+5 -3
View File
@@ -106,8 +106,10 @@
// The domain-import file decides for itself whether it is encrypted (the // The domain-import file decides for itself whether it is encrypted (the
// server checks the envelope magic, not a checkbox), so the panel offers // server checks the envelope magic, not a checkbox), so the panel offers
// the password field the same way: reveal it for a .spde file, hide and // the password field the same way: reveal it for a .spde file, hide and
// clear it for a plain .json one. An unrecognised name leaves the field // clear it for a plain .json one. With no file chosen yet there is nothing
// visible rather than guessing wrong and hiding a password the file needs. // to ask a password for, so the field stays hidden until a file names it.
// An unrecognised name leaves the field visible rather than guessing wrong
// and hiding a password the file needs.
function syncImportPasswordField(input) { function syncImportPasswordField(input) {
var form = input.closest("form"); var form = input.closest("form");
var fields = form && form.querySelector("[data-import-password-fields]"); var fields = form && form.querySelector("[data-import-password-fields]");
@@ -115,7 +117,7 @@
return; return;
} }
var name = (input.files && input.files[0] && input.files[0].name || "").toLowerCase(); var name = (input.files && input.files[0] && input.files[0].name || "").toLowerCase();
var hide = name !== "" && /\.json$/.test(name); var hide = name === "" || /\.json$/.test(name);
fields.hidden = hide; fields.hidden = hide;
if (hide) { if (hide) {
fields.querySelectorAll("input").forEach(function (pw) { fields.querySelectorAll("input").forEach(function (pw) {