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

Treeitem with visible="false" is not rendered, cause null on treeItem.$n() when toggling parent open status

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 9.6.0
    • 6.5.8.1, 9.5.0.1
    • Components
    • None

      Steps to Reproduce

      https://zkfiddle.org/sample/38ncf4t/6-Hiding-treeitem-and-using-mold-paging

      Click the "hide treeitem 2.1" button

      Click on the carret of item2 to close it

      Current Result

      item 2 doesn't close, error in JS console

      zul.sel.wpd:5159 Uncaught TypeError: Cannot read property 'style' of null
       at init._showKids (zul.sel.wpd:5159)
       at init._showKids (zk.wpd:48480)
       at init._showKids (za11y.wpd:103)
       at init.open (zul.sel.wpd:5129)
       at init.<anonymous> (zk.wpd:11140)
       at init.setOpen (zk.wpd:48480)
       at init.doClick_ (zul.sel.wpd:5568)
       at _doEvt (zk.wpd:27358)
       at HTMLDocument.<anonymous> (zk.wpd:27554)
       at HTMLDocument.dispatch (zk.wpd:5614)

      Expected Result

      no error

      Debug Information

      Treeitem widget is not rendered, cause widget.$n() to return null

      https://github.com/zkoss/zk/blob/1e82bea329ea6d627aafb435ed192e1afb85c7e5/zul/src/archive/web/js/zul/sel/Treeitem.js#L207

      No error in default mold.

      Workaround

       

       
       <script>	<script><![CDATA[
      	zk.afterLoad("zul.sel", function () {
      	    var _xTreeitem = {};
      	    zk.override(zul.sel.Treeitem.prototype, _xTreeitem, {
      			_showKids: function (open) {
      				var tc = this.treechildren;
      				if (tc)
      					for (var w = tc.firstChild, vi = tc._isRealVisible(); w; w = w.nextSibling) {
      						if(w.$n()){
      							w.$n().style.display = vi && w.isVisible() && open ? '' : 'none';
      							if (w.isOpen())
      								w._showKids(open);
      						}
      					}
      			}
      	     });
      	});
      ]]></script>
      
      

       

       

       

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

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 2 days
                2d
                Remaining:
                Time Spent - 6 hours Remaining Estimate - 1 day, 2 hours
                1d 2h
                Logged:
                Time Spent - 6 hours Remaining Estimate - 1 day, 2 hours
                6h