From e5fa66d622b3c9e7afd47dcaee1558cc1d427712 Mon Sep 17 00:00:00 2001 From: Ross Date: Fri, 5 Dec 2025 13:36:18 +0000 Subject: [PATCH] . --- cards/templates/cards/_form.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cards/templates/cards/_form.html b/cards/templates/cards/_form.html index ef391f0..cb1fb16 100644 --- a/cards/templates/cards/_form.html +++ b/cards/templates/cards/_form.html @@ -114,6 +114,18 @@ if(!label) return; if(fi.files.length === 0) label.textContent = 'No file chosen'; else label.textContent = fi.files.length > 1 ? fi.files.length + ' files selected' : fi.files[0].name; + // Prefill the name input from the filename if the name is empty + try { + const nameInput = formRoot.querySelector('input[name="name"]'); + if(nameInput && (!nameInput.value || nameInput.value.trim() === '')){ + const f = fi.files && fi.files[0]; + if(f && f.name){ + const base = f.name.replace(/\.[^/.]+$/, ''); + const title = base.replace(/[_-]+/g, ' ').split(/\s+/).map(function(w){ return w.length? (w.charAt(0).toUpperCase() + w.slice(1)) : ''; }).join(' ').trim(); + if(title) nameInput.value = title; + } + } + } catch(e){ /* ignore */ } }); // Make sure clicking the visual label triggers the input if not already clickable const outerLabel = fi.closest('.file').querySelector('.file-label');