From 719f6d47c1bd32105ee2d60119856df29319c7b3 Mon Sep 17 00:00:00 2001 From: duakayra Date: Mon, 16 Mar 2026 16:13:02 +0100 Subject: [PATCH] fix file picker handling for limited subforms --- static/midcom.datamanager/subform.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/static/midcom.datamanager/subform.js b/static/midcom.datamanager/subform.js index 45c4f95ed..bbcbeda18 100644 --- a/static/midcom.datamanager/subform.js +++ b/static/midcom.datamanager/subform.js @@ -24,6 +24,13 @@ function init_subform(id, sortable, allow_add, allow_delete) { container.trigger('sortupdate'); } new_form.trigger('subformadded'); + + // If there is exactly one file selector, we're probably in some sort of attachment list, + // so let's assume the user wants to add a file + // (at some point this should probably be made configurable) + if (new_form.find('input[type="file"]').length === 1) { + new_form.find('input[type="file"]').trigger('click'); + } } function update_add_button() { @@ -71,13 +78,4 @@ function init_subform(id, sortable, allow_add, allow_delete) { }); }); } - - add_button.on('click', function() { - // If there is exactly one file selector, we're probably in some sort of attachment list, - // so let's assume the user wants to add a file - // (at some point this should probably be made configurable) - if ($(this).prev().find('input[type="file"]').length === 1) { - $(this).prev().find('input[type="file"]').click(); - } - }); }