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

Spinner missing onChanging if _lastChg == null

XMLWordPrintable

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

      Steps to Reproduce

      run fiddle
      http://zkfiddle.org/sample/2ve4vpa/2-Splitter-no-onchanging-after-workaround
      (include onChanging workaround for #ZK-3649)
      Click outside of the 1st spinner.
      Click arrow up on 1st spinner
      Click outside again
      Click arrow up again

      Current Result

      onChanging events doesn't trigger If this._lastChange is null during _btnUp (ie blur cleaned up this._lastChg)

      Expected Result

      onChanging should trigger on each up or down arrow clicks including first click

      Debug Info

      _clearOnChanging will remove the value of _lastChg
      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/inp/InputWidget.js#L983

      while called by doBlur_() > _stopOnChanging > _clearOnChanging
      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/inp/InputWidget.js#L473
      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/inp/InputWidget.js#L969

      wgt._lastChg isn't set again before _btnUp, which cause onChanging to fail.

      Root Cause

      wgt._lastChg is null before triggering onChanging, which cause onChanging to be ignored

      Workaround

      INCLUDING WORKAROUND FOR ZK-3649

      	<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
      					this._lastChg = this.valueBeforeMouseDown?this.valueBeforeMouseDown:this._value?this.value:0;
      					var inputWidget = zul.inp.InputWidget;
      					inputWidget._stopOnChanging(this);
      					this.proxy(inputWidget._onChanging)();
      					return result;
      				},
      				_btnDown  : function() {
      					//before
      					this.valueBeforeMouseDown = this._value;
      					var result = xSpinner._btnDown .apply(this, arguments);
      					//after
      					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 - 1 hour
                1h