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

Cascader doesn't display selected item if set before render after ZK-5414

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 10.0.0
    • 9.6.4
    • None
    • Security Level: Jimmy
    • None
    • None

      Steps to Reproduce

      https://zkfiddle.org/sample/12d6shc/6-cascader-missing-label-if-selected-before-render

      Run fiddle
      select an item in cascader
      click refresh

      Current Result

      the cascader label is blank

      Expected Result

      selected item is displayed in cascader label

      Debug Information

      cascader.bind_ checks for "lastSelectedItem" to check if selection is empty during render
      The selection can be not empty while lastSelectedItem being false if the selection was made from API before rendering or invalidating the component

      Workaround

      revert previous condition: (this._selectedUuids.length > 0) //selection is not empty

      <script><![CDATA[
      		zk.afterLoad("zkmax.inp", function () {
      		    var _xCascader = {};
      		    zk.override(zkmax.inp.Cascader.prototype, _xCascader, {
      	    	   bind_: function bind_() {
      	   		      this.$supers(zkmax.inp.Cascader, 'bind_', arguments);
      	   		      jq(this.$n()).on('focusin', this.proxy(this._focusinContent)).on('focusout', this.proxy(this._focusoutContent));
      	   		      jq(this.$n('pp')).on('mousedown', ".".concat(this.$s('item')), this._doItemMouseDown.bind(this)).on('click', ".".concat(this.$s('item')), this._doItemClick.bind(this)); // handle icon
      	
      	   		      if (this._selectedUuids.length > 0) //selection is not empty
      	   		        this._updateIconClass('x');else {
      	   		        jq(this.$n('label')).css('display', 'none');
      	   		        jq(this.$n('placeholder')).css('display', 'inline-block');
      	   		      }
      	   		      zWatch.listen({
      	   		        onFloatUp: this,
      	   		        onResponse: this,
      	   		        onSize: this
      	   		      });
      	   		    }
      		     });
      		});
      	]]></script>
      

            DevChu DevChu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: