From 22e1bb3fcc3b3db1c0f5c2e6a4aecaf408c307a5 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 04 Jan 2026 18:29:46 +0000
Subject: [PATCH] Merge branch 'main' of https://github.com/jakevdwerf/jvb

---
 assets/js/concise/HandleSelection.js |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/assets/js/concise/HandleSelection.js b/assets/js/concise/HandleSelection.js
index 7981602..3034a1c 100644
--- a/assets/js/concise/HandleSelection.js
+++ b/assets/js/concise/HandleSelection.js
@@ -130,10 +130,39 @@
 		if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
 			e.preventDefault();
 
-			if (this.lastClicked) {
-				let check = this.lastClicked.querySelector(this.selectors.selectAll);
-				if (check) {
-					check.checked = true;
+			// If no lastClicked wrapper, clear everything
+			if (!this.lastClicked) {
+				this.clearSelection();
+				if (window.jvbA11y) {
+					window.jvbA11y.announce('Selection cleared');
+				}
+				return;
+			}
+
+			// First escape: clear items in the current wrapper
+			const wrapperItems = this.lastClicked.querySelectorAll(this.selectors.item);
+			const wrapperIds = Array.from(wrapperItems).map(item => this.getItemId(item));
+			const hadWrapperSelection = wrapperIds.some(id => this.selectedItems.has(id));
+
+			if (hadWrapperSelection) {
+				// Clear just the wrapper's items
+				wrapperIds.forEach(id => this.deselect(id));
+
+				// If there are still items selected elsewhere, announce partial clear
+				if (this.selectedItems.size > 0) {
+					if (window.jvbA11y) {
+						window.jvbA11y.announce('Selection cleared in current group');
+					}
+				} else {
+					if (window.jvbA11y) {
+						window.jvbA11y.announce('Selection cleared');
+					}
+				}
+			} else {
+				// Second escape or no selection in wrapper: clear everything
+				this.clearSelection();
+				if (window.jvbA11y) {
+					window.jvbA11y.announce('All selections cleared');
 				}
 			}
 		}

--
Gitblit v1.10.0