Fix card stacking overflow when vertical zone has many cards (#6925)

Previously, minOffset (10px) was enforced unconditionally, causing card
  tops to overflow zone bounds when many cards were stacked. For example,
  50 cards in a 200px zone would place the last card's top at y=490.

  Now offsets compress below minOffset when necessary to keep all card
  tops visible. The constraint is guarded by !allowBottomOverflow to
  preserve future clipping zone semantics.
This commit is contained in:
DawnFire42 2026-05-22 01:56:24 -04:00 committed by GitHub
parent 8dca14933c
commit 81a2712b92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,7 +42,19 @@ SelectZone::ZoneLayout SelectZone::computeZoneLayout(const StackLayoutParams &pa
reservedForBottomCard = params.cardHeight;
}
fitOffset = (params.totalHeight - reservedForBottomCard) / (params.cardCount - 1);
effectiveOffset = qMax(params.minOffset, qMin(params.desiredOffset, fitOffset));
if (!params.allowBottomOverflow) {
// Constrain offset so all card tops remain within zone bounds.
// With start=0, last card top at (cardCount-1) * effectiveOffset must be < totalHeight.
qreal maxOffsetForTops = params.totalHeight / (params.cardCount - 1);
fitOffset = qMin(fitOffset, maxOffsetForTops);
}
// Apply minOffset only if it fits; otherwise compress further to keep all card tops visible.
effectiveOffset = qMin(params.desiredOffset, fitOffset);
if (fitOffset >= params.minOffset) {
effectiveOffset = qMax(params.minOffset, effectiveOffset);
}
}
}
qreal stackHeight = (params.cardCount - 1) * effectiveOffset + params.cardHeight;