fix(recipes): skip stale scroller re-enable on deferred layout switch

This commit is contained in:
Will Miao
2026-08-07 14:03:13 +08:00
parent 87e3d4dea9
commit 916b8bb327
2 changed files with 95 additions and 6 deletions

View File

@@ -72,7 +72,7 @@ export class DuplicatesManager {
this.updateSelectedCount();
}
exitDuplicateMode() {
async exitDuplicateMode() {
this.inDuplicateMode = false;
this.selectedForDeletion.clear();
@@ -95,13 +95,15 @@ export class DuplicatesManager {
recipeGrid.innerHTML = '';
}
// Re-enable virtual scrolling
state.virtualScroller.enable();
// Apply a layout switch that was deferred while duplicates mode was active
// Re-enable virtual scrolling, or apply a layout switch deferred
// while duplicates mode was active (enabling the old scroller first
// would let its pending rAF render repopulate the grid after the
// new scroller is created, leaving orphaned/overlapping cards).
if (state.pendingLayoutRecreate) {
state.pendingLayoutRecreate = false;
recreateVirtualScroll('recipes');
await recreateVirtualScroll('recipes');
} else if (state.virtualScroller) {
state.virtualScroller.enable();
}
}