ZK-5364 causes external radio to no longer be selected / checked

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Critical
    • 10.2.0
    • Affects Version/s: 10.0.0
    • Component/s: None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      run fiddle in ZK 10: https://zkfiddle.org/sample/38i8g24/4-Another-new-ZK-fiddle

      Current Result

      Radio1 is not selected

      Expected Result

      radio1 is selected

      Steps to Reproduce: case 2

      1. run zk-5728.zul

      Current Result

      A is not selected (index 0)

      Expected Result

      A is selected

      Debug Information

      Caused by _jsel being not -1 when adding external radios
      https://tracker.zkoss.org/browse/ZK-5364

      when reaching _fixOnAdd, since jsel is 0 (not -1), child is always unselected by

      		if (this._jsel >= 0 && child.isSelected()) {
      			child.setSelected(false); //it will call _fixSelectedIndex()
      

      Workaround

      restore 9.6.5 behavior, might break client-bind

      	<script><![CDATA[
      		zk.afterLoad("zul.wgt", function () {
      		    var _xRadiogroup = {};
      		    zk.override(zul.wgt.Radiogroup.prototype, _xRadiogroup, {
      		        setSelectedIndex: function (selectedIndex) {
      		            if (selectedIndex < 0) selectedIndex = -1;
      		            if (this._jsel != selectedIndex) {
      		              if (this.desktop) {
      		                if (selectedIndex < 0) {
      		                  this.getSelectedItem().setSelected(false);
      		                } else {
      		                  this.getItemAtIndex(selectedIndex).setSelected(true);
      		                }
      		              }
      		              /* WORKAROUND: remove _jsel from setSelectedIndex, restore to 9.6.5*/
      		              //this._jsel = selectedIndex;
      		            }
      		            return this;
      		          }
      		     });
      		});
      	]]></script>
      

        1. Zk5728.java
          0.9 kB
        2. zk-5728.zul
          0.1 kB

            Assignee:
            DevChu
            Reporter:
            MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: