diff options
5 files changed, 60 insertions, 19 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java index 765df8867d..ff60fe154d 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java @@ -975,10 +975,6 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> public void renderCalendar(boolean updateDate) { if (parent instanceof VAbstractPopupCalendar && !((VAbstractPopupCalendar) parent).popup.isShowing()) { - if (getDate() == null) { - // no date set, cannot pre-render yet - return; - } // a popup that isn't open cannot possibly need a focus change event updateDate = false; } diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java index c7fe9e14be..140d8e3ce4 100644 --- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java @@ -906,6 +906,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, // ComboBox itself may be incorrectly positioned, don't adjust // popup position yet. Width calculations must be performed // anyway to avoid flickering. + setPopupPosition(left, top); return; } if (left > comboBoxLeft 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() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChange.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChange.java index 55b2823a1d..62ecb8428c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChange.java +++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChange.java @@ -30,9 +30,16 @@ public class DateFieldMonthResolutionStatusChange extends AbstractTestUI { dateField.setRangeEnd(LocalDate.of(2020, 1, 1)); }); + Button resetValueButton = new Button("Reset value"); + resetValueButton.setId("resetValue"); + resetValueButton.addClickListener(event -> { + dateField.setValue(LocalDate.now()); + }); + addComponent(dateField); addComponent(dateReadOnlySwitch); addComponent(addRangeButton); + addComponent(resetValueButton); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChangeTest.java index 58a926546c..0473a582e8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldMonthResolutionStatusChangeTest.java @@ -3,6 +3,7 @@ package com.vaadin.tests.components.datefield; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.openqa.selenium.By; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.DateFieldElement; @@ -35,4 +36,22 @@ public class DateFieldMonthResolutionStatusChangeTest assertEquals("Unexpected date change.", "1/19", df.getValue()); } + @Test + public void testPopupOpenWithDateNotInRange() { + openTestURL(); + DateFieldElement df = $(DateFieldElement.class).first(); + + // switch read-only state + $(ButtonElement.class).id("readOnly").click(); + // set value before range + $(ButtonElement.class).id("resetValue").click(); + // add range, previously set date is not in range + $(ButtonElement.class).id("addRange").click(); + + // Test that popup still opens + df.openPopup(); + waitForElementPresent(By.className("v-datefield-popup")); + assertElementPresent(By.className("v-datefield-popup")); + } + } |