Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3649

Spinner doesn't send onChanging events following ZK-3530

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.5.0
    • 8.0.5
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      run fiddle:
      http://zkfiddle.org/sample/1gsdtbq/1-Splitter-no-onchanging
      click on arrows up or down on the first spinner

      Current Result

      onChanging is not called clicks.
      onChanging is evaluated during blur

      Expected Result

      onChanging should be called for each click

      Debug Info

      Most components will perform some variation of

      this.proxy(inputWidget._onChanging)();
      

      when triggering onChanging (usually inside a timeout)
      Spinner calls onChanging directly during _btnUp
      https://github.com/zkoss/zk/blob/884e074c3ab999798dcf38b01564ec1f4c940818/zul/src/archive/web/js/zul/inp/Spinner.js#L158

      which then in turn invoke the static _onChanging here:
      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/inp/InputWidget.js#L424

      in this scenario, when the actual onChanging function is called here:
      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/inp/InputWidget.js#L941
      the 'this' object doesn't refer to the spinner wgt (as it would in a proxied method) but to the function object instead. since this is invalid, _onChanging fails.

      Root Cause

      Change of architecture
      https://github.com/zkoss/zk/commit/3c05a5010116e6cd70a751daf2735206cd9487b3

      Workaround

      	<script><![CDATA[
      		zk.afterLoad('zul.inp', function() {
      			var xSpinner = {};
      			zk.override(zul.inp.Spinner.prototype, xSpinner ,{
      				_btnUp  : function() {
      					//before
      					var result = xSpinner._btnUp .apply(this, arguments);
      					//after
      					var inputWidget = zul.inp.InputWidget;
      					inputWidget._stopOnChanging(this);
      					this.proxy(inputWidget._onChanging)();
      					return result;
      				}
      			});//zk.override
      		});//zk.afterLoad
      	]]></script>
      

            wenninghsu wenninghsu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h