[TIMOB-27625] Android: Setting picker's minDate/maxDate after opening window not correctly applied
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-05-04T12:58:06.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.0.2 |
Components | n/a |
Labels | n/a |
Reporter | Teun Klijn |
Assignee | Joshua Quick |
Created | 2019-11-22T15:10:14.000+0000 |
Updated | 2020-05-04T12:58:06.000+0000 |
Description
When you set maxDate twice on a Ti.UI.Picker the first maxDate is still the maximum date I can set.
*To reproduce*
Press "Set Max Date"
Try to set the picker to the new maxDate
var maxDate = new Date();
var window = Ti.UI.createWindow({
layout: "vertical",
backgroundColor: "#454441"
});
var picker = Ti.UI.createPicker({
type: Ti.UI.PICKER_TYPE_DATE,
maxDate: maxDate
});
window.add(picker);
var button = Ti.UI.createButton({
title: "Set Max Date"
});
button.addEventListener("click", function() {
picker.maxDate = new Date(maxDate.getFullYear() + 1, maxDate.getMonth(), maxDate.getDate());
});
window.add(button);
window.open();
*Expected behavior*
The user is able to set the date to the new maxDate.
*Actual behavior*
The picker keeps resetting to the first maxDate.
*Note*
I think this is because the TiUIDatePicker class is using a maxDate variable (I think minDate has the same problem) to check if a date change is allowed (line 165), but it's only updating this property in processProperties and not in propertyChanged.
I'm able to work around this issue by setting a high maxDate at initialization before I start updating the maxDate. This confirms my suspicion above.
I have confirmed this is a valid issue and can be reproduced. Moving to TIMOB.
-PR:- https://github.com/appcelerator/titanium_mobile/pull/11369 Closing in favor of below PR.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/11621 PR (9.0.x): https://github.com/appcelerator/titanium_mobile/pull/11622
FR Passed for Master and 9_0_X, waiting on Jenkins build
merged to master and 9_0_X
*Closing ticket.* Fix verified in SDK version 9.1.0.v20200501090150 and 9.0.2.v20200430111828 Test and other information can be found at: PR (master): https://github.com/appcelerator/titanium_mobile/pull/11621 PR (9.0.x): https://github.com/appcelerator/titanium_mobile/pull/11622