Commit a8dd4086 authored by Ionel Popescu's avatar Ionel Popescu Committed by Commit Bot

Avoid resizing when navigating from date view to year list view.

This CL stops resizing the popup when navigating from date view to year
list view. The resize of the popup could cause a weird behavior when
the popup is moved from above the in-page control to below it due to
height constraints.

Instead of resizing the popup, the calendarTableView visibility is
changed to either visible or hidden.

Bug: 1001348
Change-Id: Ia2e5ff286a231b685265f46b849d9e636ddf133b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795318Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#695695}
parent fa3e6ebf
......@@ -2259,7 +2259,7 @@ function YearListView(minimumMonth, maximumMonth) {
YearListView.prototype = Object.create(ListView.prototype);
YearListView._Height = YearListCell._SelectedHeight - 1;
YearListView._VisibleYearsRefresh = 3;
YearListView._VisibleYearsRefresh = 4;
YearListView._HeightRefresh = YearListCell._SelectedHeightRefresh - 1 + YearListView._VisibleYearsRefresh * YearListCell._HeightRefresh;
YearListView.GetHeight = function() {
if (global.params.isFormControlsRefreshEnabled) {
......@@ -3842,7 +3842,11 @@ CalendarPicker.prototype.onWindowResize = function(event) {
CalendarPicker.prototype.onYearListViewDidHide = function(sender) {
this.monthPopupView.hide();
this.calendarHeaderView.setDisabled(false);
this.adjustHeight();
if (global.params.isFormControlsRefreshEnabled) {
this.calendarTableView.element.style.visibility = 'visible';
} else {
this.adjustHeight();
}
};
/**
......@@ -3880,7 +3884,11 @@ CalendarPicker.prototype.onMonthPopupButtonClick = function(sender) {
clientRect.height);
this.monthPopupView.show(this.currentMonth(), calendarTableRect);
this.calendarHeaderView.setDisabled(true);
this.adjustHeight();
if (global.params.isFormControlsRefreshEnabled) {
this.calendarTableView.element.style.visibility = 'hidden';
} else {
this.adjustHeight();
}
};
CalendarPicker.prototype._setConfig = function(config) {
......@@ -3935,7 +3943,7 @@ CalendarPicker.prototype.adjustHeight = function() {
var numberOfRows = global.params.isFormControlsRefreshEnabled ? CalendarPicker.VisibleRowsRefresh : rowForLastDayInMonth - rowForFirstDayInMonth + 1;
var calendarTableViewHeight =
CalendarTableHeaderView.GetHeight() + numberOfRows * DayCell.GetHeight() + CalendarTableView.GetBorderWidth() * 2 + CalendarTableView.GetTodayButtonHeight();
var height = (this.monthPopupView.isVisible ? YearListView.GetHeight() : calendarTableViewHeight) +
var height = (this.monthPopupView.isVisible && !global.params.isFormControlsRefreshEnabled ? YearListView.GetHeight() : calendarTableViewHeight) +
CalendarHeaderView.Height + CalendarHeaderView.BottomMargin + CalendarPicker.Padding * 2 +
CalendarPicker.BorderWidth * 2;
this.setHeight(height);
......
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../forms/resources/common.js"></script>
<script src="../../../forms/resources/picker-common.js"></script>
<script src="../../../forms/calendar-picker/resources/calendar-picker-common.js"></script>
</head>
<body>
<input type=date id=date value="2019-09-10">
<script>
let t = async_test('Test year list view size');
function test1() {
var dateViewHeight = popupWindow.global.picker.height();
clickMonthPopupButton();
if (popupWindow.global.params.isFormControlsRefreshEnabled) {
assert_equals(dateViewHeight, popupWindow.global.picker.height());
} else {
assert_not_equals(dateViewHeight, popupWindow.global.picker.height());
}
}
t.step(() => {
openPicker(document.getElementById('date'), t.step_func_done(test1));
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment