From a81f7043fc44382775f9afac48e4c7a651e7ac6c Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 04 Jan 2026 18:29:10 +0000
Subject: [PATCH] =PopulateForm.js and ContentRoutes.php minor changes

---
 assets/js/concise/UploadManager.js |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/assets/js/concise/UploadManager.js b/assets/js/concise/UploadManager.js
index b48d38c..7301390 100644
--- a/assets/js/concise/UploadManager.js
+++ b/assets/js/concise/UploadManager.js
@@ -1279,7 +1279,7 @@
 		const grid = element.querySelector('.item-grid');
 		if (grid) {
 			grid.dataset.groupId = groupId;
-			this.createSortableForGrid(fieldId, grid, groupId);
+			this.createSortable(fieldId, grid, groupId);
 		}
 
 		let storedData = this.stores.groups.data.has(groupId)
@@ -1587,7 +1587,25 @@
 			chosenClass: 'chosen',
 			dragClass: 'dragging',
 
-			onStart: () => this.syncSortableSelection(fieldId),
+			onStart: (evt) => {
+				// Get the dragged item's ID
+				const draggedItem = evt.item;
+				const uploadId = draggedItem?.dataset.uploadId;
+
+				// Get the selected items Set for this field
+				const selectedItems = this.selected.get(fieldId);
+
+				// If the dragged item isn't selected, select it
+				if (uploadId && (!selectedItems || !selectedItems.has(uploadId))) {
+					const handler = this.selectionHandlers.get(fieldId);
+					if (handler) {
+						handler.select(uploadId);
+					}
+				}
+
+				// Sync all selections to Sortable
+				this.syncSortableSelection(fieldId);
+			},
 			onEnd: (evt) => this.sortableDrop(evt, fieldId),
 		});
 
@@ -1739,6 +1757,10 @@
 			})
 		]);
 
+		if (this.restoreModal) {
+			this.cleanupRestore();
+		}
+
 		this.a11y.announce('Cache cleared for this page');
 	}
 

--
Gitblit v1.10.0