Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 401780

Summary: DateTimeCalendar destroys itself on ESC
Product: [RT] RAP Reporter: Markus Duft <markus.duft>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P1    
Version: 2.0   
Target Milestone: 2.1 M1   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Markus Duft CLA 2013-02-26 07:17:49 EST
When pressing ESC on a DateTimeCalendar, an exception in JS is raised:

TypeError: Cannot call method 'getDate' of null
    at [object Object]._onChangeDate (http://127.0.0.1:10080/rwt-resources/rap-client.js:66120:31)
    at [object Object]._dispatchEvent (http://127.0.0.1:10080/rwt-resources/rap-client.js:6476:18)
    at [object Object].dispatchEvent (http://127.0.0.1:10080/rwt-resources/rap-client.js:6406:12)
    at [object Object].createDispatchChangeEvent (http://127.0.0.1:10080/rwt-resources/rap-client.js:6373:14)
    at [object Object].setDate (eval at <anonymous> (http://127.0.0.1:10080/rwt-resources/rap-client.js:4511:28))
    at [object Object]._onkeypress (http://127.0.0.1:10080/rwt-resources/rap-client.js:62926:20)
    at [object Object]._onKeyPress (http://127.0.0.1:10080/rwt-resources/rap-client.js:66134:22)
    at [object Object]._dispatchEvent (http://127.0.0.1:10080/rwt-resources/rap-client.js:6476:18)
    at [object Object].dispatchEvent (http://127.0.0.1:10080/rwt-resources/rap-client.js:6406:12)
    at Object._processKeyEvent (http://127.0.0.1:10080/rwt-resources/rap-client.js:17290:17)

the problem is, that the base.Calendar widget has this _onkeypress:

         case "Escape":
            if (this.getDate() != null) {
              this.setDate(null);
              evt.preventDefault();
              evt.stopPropagation();
              return true;
            }

and the DateTimeCalendar has this _onChangeDate:

    _onChangeDate : function() {
      var date = this._calendar.getDate();
      this._sendChanges( date.getDate(), date.getMonth(), date.getFullYear() );
    },

obviously, setDate(null) will cause _onChangeDate to dereference null with date.getDate() in that case.

also see http://www.eclipse.org/forums/index.php/t/457371/
Comment 1 Ivan Furnadjiev CLA 2013-02-26 11:10:27 EST
Reproducible with Controls Demo -> DateTime tab:
1. Select CALENDAR
2. Focus the DateTime controls - click on the calendar
3. Press ESC
Comment 2 Ivan Furnadjiev CLA 2013-02-26 11:37:38 EST
Fixed in master with commit f7e7962ea94dc98ee41146cbca958a7b5bd98882.