Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27625] Android: Setting picker's minDate/maxDate after opening window not correctly applied

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-05-04T12:58:06.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.2
Componentsn/a
Labelsn/a
ReporterTeun Klijn
AssigneeJoshua Quick
Created2019-11-22T15:10:14.000+0000
Updated2020-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.

Comments

  1. Yordan Banev 2019-11-25

    I have confirmed this is a valid issue and can be reproduced. Moving to TIMOB.
  2. Yordan Banev 2019-11-26

    -PR:- https://github.com/appcelerator/titanium_mobile/pull/11369 Closing in favor of below PR.
  3. Joshua Quick 2020-04-11

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11621 PR (9.0.x): https://github.com/appcelerator/titanium_mobile/pull/11622
  4. Samir Mohammed 2020-04-27

    FR Passed for Master and 9_0_X, waiting on Jenkins build
  5. Christopher Williams 2020-04-28

    merged to master and 9_0_X
  6. Samir Mohammed 2020-05-04

    *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

JSON Source