diff options
-rwxr-xr-x | client/src/main/java/com/vaadin/client/widgets/Grid.java | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index cd7399fba4..302ccb71b0 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -4366,6 +4366,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, private boolean refreshBodyRequested = false; + private boolean resizeRequested = false; + private boolean resizeRefreshScheduled = false; + private DragAndDropHandler.DragAndDropCallback headerCellDndCallback = new DragAndDropCallback() { private final AutoScrollerCallback autoScrollerCallback = new AutoScrollerCallback() { @@ -9264,23 +9267,38 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, /* * Delay calculation to be deferred so Escalator can do it's magic. */ - Scheduler.get().scheduleFinally(() -> { - if (escalator - .getInnerWidth() != autoColumnWidthsRecalculator.lastCalculatedInnerWidth) { - recalculateColumnWidths(); - } + resizeRequested = true; + if (!resizeRefreshScheduled) { + resizeRefreshScheduled = true; + Scheduler.get().scheduleFixedDelay(() -> { + if (!resizeRequested) { + doRefreshOnResize(); + resizeRefreshScheduled = false; + return false; + } else { + resizeRequested = false; + return true; + } + }, 50); + } + } + + private void doRefreshOnResize() { + if (escalator + .getInnerWidth() != autoColumnWidthsRecalculator.lastCalculatedInnerWidth) { + recalculateColumnWidths(); + } - // Vertical resizing could make editor positioning invalid so it - // needs to be recalculated on resize - if (isEditorActive()) { - editor.updateVerticalScrollPosition(); - } + // Vertical resizing could make editor positioning invalid so it + // needs to be recalculated on resize + if (isEditorActive()) { + editor.updateVerticalScrollPosition(); + } - // if there is a resize, we need to refresh the body to avoid an - // off-by-one error which occurs when the user scrolls all the - // way to the bottom. - refreshBody(); - }); + // if there is a resize, we need to refresh the body to avoid an + // off-by-one error which occurs when the user scrolls all the + // way to the bottom. + refreshBody(); } private double getEscalatorInnerHeight() { |