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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: 9.5.0.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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

      Listitem 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

      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>
      
      

       

       

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: