diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2019-06-25 08:37:08 +0300 |
---|---|---|
committer | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2019-06-25 08:37:08 +0300 |
commit | 973731763c2aa7138584646c06385c4e8340a7ac (patch) | |
tree | ea7113b338caddd63963d137cb042d79301c447d /client | |
parent | bc576f48aa4fd51114cba4426e7ab95e633ac719 (diff) | |
download | vaadin-framework-973731763c2aa7138584646c06385c4e8340a7ac.tar.gz vaadin-framework-973731763c2aa7138584646c06385c4e8340a7ac.zip |
Clicking on DateField pop-up should select Month/Year (#11531)
* Clicking on DateField pop-up should select Month/Year
In Year/Month Resolution DateField should select the value, when user clicks on pop-up
Fixes #8447
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java | 14 |
1 files changed, 14 insertions, 0 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 8f32d35acb..c049a25a53 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java @@ -30,6 +30,7 @@ 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; @@ -49,6 +50,7 @@ import com.google.gwt.event.dom.client.MouseUpEvent; import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FlexTable; @@ -580,6 +582,15 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> // Set ID to be referenced from focused date or calendar panel Element monthYearElement = getFlexCellFormatter().getElement(0, 2); AriaHelper.ensureHasId(monthYearElement); + Event.sinkEvents(monthYearElement, Event.ONCLICK); + Event.setEventListener(monthYearElement, event -> { + // Don't handle header clicks if resolution in below month + if (!isEnabled() || isReadonly() || isBelowMonth(getResolution())) { + return; + } + selectFocused(); + onSubmit(); + }); if (!needsBody) { Roles.getGridRole().setAriaLabelledbyProperty(getElement(), Id.of(monthYearElement)); @@ -591,6 +602,9 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> "<span class=\"" + parent.getStylePrimaryName() + "-calendarpanel-month\">" + monthName + " " + year + "</span>"); + if (!isBelowMonth(getResolution())) { + monthYearElement.addClassName("header-month-year"); + } } private void updateControlButtonRangeStyles(boolean needsMonth) { |