Grid.decreaseColumnWidth: prevent scrolling away from focused column when reaching minimum width

This commit is contained in:
Peter Fajdiga
2023-12-24 12:50:52 +01:00
parent 768d95450d
commit fb40bd9592

View File

@@ -224,12 +224,16 @@ class Grid {
const deltaWidth = rightSpace - leftInvisibleWidth;
column.adjustWidth(deltaWidth, true);
console.assert(leftOffScreenColumn !== null);
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftOffScreenColumn!, rightVisibleColumn));
const newVisibleWidth = rightVisibleColumn.getRight() - leftOffScreenColumn!.getLeft();
const leftVisibleColumn = newVisibleWidth <= visibleRange.getWidth() ? leftOffScreenColumn! : this.getNextColumn(leftOffScreenColumn!)!;
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftVisibleColumn, rightVisibleColumn));
} else {
const deltaWidth = leftSpace - rightInvisibleWidth;
column.adjustWidth(deltaWidth, true);
console.assert(rightOffScreenColumn !== null);
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftVisibleColumn, rightOffScreenColumn!));
const newVisibleWidth = rightOffScreenColumn!.getRight() - leftVisibleColumn.getLeft();
const rightVisibleColumn = newVisibleWidth <= visibleRange.getWidth() ? rightOffScreenColumn! : this.getPrevColumn(rightOffScreenColumn!)!;
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftVisibleColumn, rightVisibleColumn));
}
}