Fix: pendingSelections sync and chips toolbar display

1. Fix Select All not persisting in list view:
   - Updated Select All handler to populate pendingSelections array
   - Updated Clear selection handler to clear pendingSelections for list view
   - Updated dropdown item click to add/remove from pendingSelections
   - Updated chip remove handler to filter pendingSelections

2. Fix chips toolbar (search/delete all) not showing:
   - PHP renderer was pre-creating chips-wrapper without toolbar
   - JS ensureChipsWrapper was skipping because wrapper existed
   - Removed wrapper from PHP so JS creates complete wrapper with toolbar

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 18:41:22 +00:00
parent 743e9c8020
commit 5ee4617cb1
5 changed files with 85 additions and 4 deletions

View File

@@ -1169,7 +1169,14 @@
$row = $excludeRow;
}
// Ensure pendingSelections is initialized
if (!self.pendingSelections) self.pendingSelections = [];
if (isSelected) {
// Remove from pending selections
self.pendingSelections = self.pendingSelections.filter(function(s) {
return parseInt(s.id, 10) !== parseInt(id, 10);
});
self.removeSelection($picker, id);
$item.toggleClass('selected');
self.serializeAllBlocks($row);
@@ -1186,11 +1193,20 @@
if (currentSelection) {
var newEntityType = self.activeGroup.blockType;
self.showReplaceConfirmation(currentSelection, { name: name, entityType: newEntityType }, function() {
// Add to pending selections
self.pendingSelections.push({ id: id, name: name, data: $item.data() });
self.addSelection($picker, id, name, $item.data());
$item.addClass('selected');
self.serializeAllBlocks($row);
});
} else {
// Add to pending selections
var exists = self.pendingSelections.some(function(s) {
return parseInt(s.id, 10) === parseInt(id, 10);
});
if (!exists) {
self.pendingSelections.push({ id: id, name: name, data: $item.data() });
}
self.addSelection($picker, id, name, $item.data());
$item.toggleClass('selected');
self.serializeAllBlocks($row);
@@ -1206,6 +1222,13 @@
var $row = $(this).closest('.group-include, .exclude-row');
var id = $chip.data('id');
// Also remove from pending selections if dropdown is open
if (self.pendingSelections) {
self.pendingSelections = self.pendingSelections.filter(function(s) {
return parseInt(s.id, 10) !== parseInt(id, 10);
});
}
self.removeSelection($picker, id);
self.serializeAllBlocks($row);
@@ -1296,6 +1319,9 @@
$row = $excludeRow;
}
// Ensure pendingSelections is initialized
if (!self.pendingSelections) self.pendingSelections = [];
var $visibleItems = self.$dropdown.find('.dropdown-item:visible');
$visibleItems.each(function() {
if (!$(this).hasClass('selected')) {
@@ -1309,6 +1335,18 @@
return; // Skip this item
}
// Add to pending selections for Save button
var exists = self.pendingSelections.some(function(s) {
return parseInt(s.id, 10) === parseInt(id, 10);
});
if (!exists) {
self.pendingSelections.push({
id: id,
name: name,
data: $(this).data()
});
}
self.addSelectionNoUpdate($picker, id, name, $(this).data());
$(this).addClass('selected');
}
@@ -1360,6 +1398,9 @@
$row = $excludeRow;
}
// Clear pending selections for list view too
self.pendingSelections = [];
var $chips = $picker.find('.entity-chips');
$chips.empty().removeClass('chips-expanded chips-collapsed');
self.$dropdown.find('.dropdown-item').removeClass('selected');