summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorZhe Sun <31067185+ZheSun88@users.noreply.github.com>2020-02-04 14:43:50 +0200
committerGitHub <noreply@github.com>2020-02-04 14:43:50 +0200
commita9d09be500c1f00b7c797701c6bb343c2308d2cb (patch)
tree756c7eb7ca89b6a7ea6f85548661a73c6ceb14db /client
parentd32798bbdf6ffd49dc15ac1ca664eafcece04410 (diff)
downloadvaadin-framework-a9d09be500c1f00b7c797701c6bb343c2308d2cb.tar.gz
vaadin-framework-a9d09be500c1f00b7c797701c6bb343c2308d2cb.zip
Cherry picks for 8.10 final release (#11883)
* Don't reset date to current at DateField state (e.g. read-only) updates. (#11879) - DateFields with month or year resolution should not get their date reset to current date if the field's state is updated (e.g. by changing read-only status or adding a range). Fixes: #11864, #11605 * Update Navigator.getState() JavaDoc to be more accurate (#11876) Fixes: https://github.com/vaadin/framework/issues/11875 Co-authored-by: Anna Koskinen <Ansku@users.noreply.github.com> Co-authored-by: Tatu Lund <tatu@vaadin.com>
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java28
1 files changed, 20 insertions, 8 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 c049a25a53..8fde0264e4 100644
--- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java
+++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java
@@ -16,6 +16,8 @@
package com.vaadin.client.ui;
+import static com.vaadin.client.DateTimeService.asTwoDigits;
+
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -30,7 +32,6 @@ import com.google.gwt.aria.client.Roles;
import com.google.gwt.aria.client.SelectedValue;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -56,14 +57,11 @@ import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.InlineHTML;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.BrowserInfo;
import com.vaadin.client.DateTimeService;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.shared.util.SharedUtil;
-import static com.vaadin.client.DateTimeService.asTwoDigits;
-
/**
* Abstract calendar panel to show and select a date using a resolution. The
* class is parameterized by the date resolution enumeration type.
@@ -963,7 +961,17 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
* resolution of the calendar is changed and no date has been
* selected.
*/
+ @SuppressWarnings("rawtypes")
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;
+ }
doRenderCalendar(updateDate);
initialRenderDone = true;
@@ -986,11 +994,15 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>>
getDateField().getStylePrimaryName() + "-calendarpanel");
if (focusedDate == null) {
- Date now = new Date();
+ Date date = getDate();
+ if (date == null) {
+ date = new Date();
+ }
// focusedDate must have zero hours, mins, secs, millisecs
- focusedDate = new FocusedDate(now.getYear(), now.getMonth(),
- now.getDate());
- displayedMonth = new FocusedDate(now.getYear(), now.getMonth(), 1);
+ focusedDate = new FocusedDate(date.getYear(), date.getMonth(),
+ date.getDate());
+ displayedMonth = new FocusedDate(date.getYear(), date.getMonth(),
+ 1);
}
if (updateDate && !isDay(getResolution())