fix(panel): keep the import password field hidden until a file is chosen

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 9745edd132
commit 76f04f93d1
+5 -3
View File
@@ -106,8 +106,10 @@
// The domain-import file decides for itself whether it is encrypted (the
// 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
// clear it for a plain .json one. An unrecognised name leaves the field
// visible rather than guessing wrong and hiding a password the file needs.
// clear it for a plain .json one. With no file chosen yet there is nothing
// 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) {
var form = input.closest("form");
var fields = form && form.querySelector("[data-import-password-fields]");
@@ -115,7 +117,7 @@
return;
}
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;
if (hide) {
fields.querySelectorAll("input").forEach(function (pw) {