From 0eb457fbc3868352966b185ce49c59733c512721 Mon Sep 17 00:00:00 2001 From: Chuck Date: Thu, 8 Jan 2026 12:31:26 -0500 Subject: [PATCH] fix: Update upload button onclick when reindexing custom feed rows Fix removeCustomFeedRow to update button onclick handlers that reference file input IDs with _logo_ when rows are reindexed after deletion. Previously, after deleting a row, the upload button's onclick still referenced the old file input ID, causing the upload functionality to fail. Now properly updates: - getElementById('..._logo_') patterns in onclick handlers - Other _logo_ patterns in button onclick strings - Function parameter indices in onclick handlers This ensures upload buttons continue to work correctly after row deletion. --- web_interface/templates/v3/base.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/web_interface/templates/v3/base.html b/web_interface/templates/v3/base.html index 4263a091..3b4a026c 100644 --- a/web_interface/templates/v3/base.html +++ b/web_interface/templates/v3/base.html @@ -4920,6 +4920,29 @@ input.setAttribute('onchange', onchange.replace(/,\s*\d+\s*,/, `, ${index},`)); } } + // Update button onclick handlers that reference file input IDs with _logo_ + // Check for buttons (not just inputs) and update onclick if it contains _logo_ references + if (input.tagName === 'BUTTON') { + const onclick = input.getAttribute('onclick'); + if (onclick) { + let updatedOnclick = onclick; + // Replace getElementById('..._logo_') with getElementById('..._logo_') + updatedOnclick = updatedOnclick.replace( + /getElementById\(['"]([^'"]*_logo_)\d+['"]\)/g, + `getElementById('$1${index}')` + ); + // Also handle patterns like _logo_ in other contexts + updatedOnclick = updatedOnclick.replace( + /(['"])([^'"]*_logo_)\d+(['"])/g, + `$1$2${index}$3` + ); + // Update function call parameters (handleCustomFeedLogoUpload, removeCustomFeedRow, etc.) + updatedOnclick = updatedOnclick.replace(/,\s*\d+\s*,/g, `, ${index},`); + if (updatedOnclick !== onclick) { + input.setAttribute('onclick', updatedOnclick); + } + } + } }); }); }