You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Correct lane assignments when lane count changes dynamically
6
+
7
+
Fixed a critical bug where changing the number of lanes dynamically would cause layout breakage with incorrect lane assignments. When the lane count changed (e.g., from 3 to 2 columns in a responsive masonry layout), some virtual items would retain their old lane numbers, causing out-of-bounds errors and broken layouts.
8
+
9
+
**Root Cause**: After clearing measurements cache on lane change, the virtualizer was incorrectly restoring data from `initialMeasurementsCache`, which contained stale lane assignments from the previous lane count.
10
+
11
+
**Fix**: Skip `initialMeasurementsCache` restoration during lane transitions by checking the `lanesSettling` flag. This ensures all measurements are recalculated with correct lane assignments for the new lane count.
12
+
13
+
**Before**:
14
+
15
+
```typescript
16
+
// With lanes = 2
17
+
virtualItems.forEach((item) => {
18
+
columns[item.lane].push(item) // ❌ Error: item.lane could be 3
19
+
})
20
+
```
21
+
22
+
**After**:
23
+
24
+
```typescript
25
+
// With lanes = 2
26
+
virtualItems.forEach((item) => {
27
+
columns[item.lane].push(item) // ✅ item.lane is always 0 or 1
28
+
})
29
+
```
30
+
31
+
This fix is essential for responsive masonry layouts where column count changes based on viewport width. No performance impact as it only affects the lane change transition path.
0 commit comments