From b38f03c0e7218762d90fa5092696b127f24f36db Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 25 Jan 2026 07:07:26 +0000
Subject: [PATCH] =Some logical flaws in Queue.php, Queue.js, ContentExecutor.php, UploadExecutor.php - particularly with timeline ordering, frontend queue updates, etc

---
 assets/js/concise/UtilityFunctions.js |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/assets/js/concise/UtilityFunctions.js b/assets/js/concise/UtilityFunctions.js
index df3c75d..27944aa 100644
--- a/assets/js/concise/UtilityFunctions.js
+++ b/assets/js/concise/UtilityFunctions.js
@@ -413,27 +413,34 @@
 	}
 }
 
-window.prefixInput = function(input, prefix, replace = false) {
+window.prefixInput = function(input, prefix, wrapper = null, replace = false) {
 	if (!input) {
 		console.warn('prefixInput called with null/undefined input');
 		return;
 	}
-	let newId = replace ? prefix : `${prefix}${input.name}`;
-	if (input.labels && input.labels.length > 0) {
-		input.labels?.forEach(label => {
-			label.htmlFor = newId;
-		});
-	} else if (input.previousElementSibling?.tagName === 'label') {
-		let label = input.previousElementSibling;
-		if (label) label.htmlFor = newId;
-	} else if (input.nextElementSibling?.tagName === 'label') {
-		let label = input.nextElementSibling;
-		if (label) label.htmlFor = newId;
-	}else {
-		let label = input.closest('[data-field]')?.querySelector(`label[for="${input.id}"]`);
-		if (label) {
-			label.htmlFor = newId;
-		}
+	const oldId = input.id;
+	const newId = replace ? prefix : `${prefix}${input.name}`;
+
+	// Search for label within wrapper if provided, otherwise use existing logic
+	let label = null;
+
+	if (wrapper) {
+		// Most reliable: search within wrapper by old ID
+		label = wrapper.querySelector(`label[for="${oldId}"]`);
+	} else if (input.labels && input.labels.length > 0) {
+		// Fallback to input.labels if no wrapper provided
+		label = input.labels[0];
+	} else if (input.previousElementSibling?.tagName === 'LABEL') {
+		label = input.previousElementSibling;
+	} else if (input.nextElementSibling?.tagName === 'LABEL') {
+		label = input.nextElementSibling;
+	} else {
+		// Final fallback: search up the tree
+		label = input.closest('[data-field]')?.querySelector(`label[for="${oldId}"]`);
+	}
+
+	if (label) {
+		label.htmlFor = newId;
 	}
 
 	input.id = newId;

--
Gitblit v1.10.0