| | |
| | | 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'); |
| | | } |
| | | } |
| | | } |