瀏覽代碼

Prevent a gap within Grid rows in some resize situations. (#11918)

Fixes #11892
tags/8.11.0.alpha1
Anna Koskinen 4 年之前
父節點
當前提交
1313bbbe3b
No account linked to committer's email address
共有 1 個文件被更改,包括 25 次插入3 次删除
  1. 25
    3
      client/src/main/java/com/vaadin/client/widgets/Escalator.java

+ 25
- 3
client/src/main/java/com/vaadin/client/widgets/Escalator.java 查看文件

// for a gap if a details row is later closed (e.g. by user) // for a gap if a details row is later closed (e.g. by user)
final int addToBottom = Math.min(rowDiff, final int addToBottom = Math.min(rowDiff,
getRowCount() - logicalTargetIndex); getRowCount() - logicalTargetIndex);
final int addToTop = rowDiff - addToBottom;
final int addToTop = Math.max(rowDiff - addToBottom, 0);


if (addToTop > 0) { if (addToTop > 0) {
fillAndPopulateEscalatorRowsIfNeeded(0, fillAndPopulateEscalatorRowsIfNeeded(0,
updateTopRowLogicalIndex(-addToTop); updateTopRowLogicalIndex(-addToTop);
} }
if (addToBottom > 0) { if (addToBottom > 0) {
fillAndPopulateEscalatorRowsIfNeeded(visualTargetIndex,
logicalTargetIndex, addToBottom);
// take into account that rows may have got added to top as
// well, affects visual but not logical indexing
fillAndPopulateEscalatorRowsIfNeeded(
visualTargetIndex + addToTop, logicalTargetIndex,
addToBottom);

// adding new rows due to resizing may have created a gap in
// the middle, check whether the existing rows need moving
double rowTop = getRowTop(oldTopRowLogicalIndex);
if (rowTop > getRowTop(visualRowOrder.get(addToTop))) {
for (int i = addToTop; i < visualTargetIndex; i++) {

final TableRowElement tr = visualRowOrder.get(i);

setRowPosition(tr, 0, rowTop);
rowTop += getDefaultRowHeight();
SpacerContainer.SpacerImpl spacer = spacerContainer
.getSpacer(oldTopRowLogicalIndex + i);
if (spacer != null) {
spacer.setPosition(0, rowTop);
rowTop += spacer.getHeight();
}
}
}
} }
} else if (rowDiff < 0) { } else if (rowDiff < 0) {
// rows need to be removed // rows need to be removed

Loading…
取消
儲存