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

setWidth(null) causes a JavaScript error

XMLWordPrintable

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

      Steps to Reproduce

      1. load the zul below
      2. click the button twice
      <zk>
      
      <tree width="400px" height="120px">
      	<treecols>
      		<treecol width="200px" label="1" />
      		<treecol id="secondCol" label="2" />
      	</treecols>
      	<treechildren>
      		<treeitem forEach="A, B, C, D, E">
      			<treerow>
      				<treecell label="${each}" />
      				<treecell label="${each}" />
      			</treerow>
      		</treeitem>
      	</treechildren>
      </tree>
      	<button label="Zoom" onClick='secondCol.setWidth(secondCol.getWidth() == null ? "500px" : null)' />
      </zk>
      

      Current Result

      Uncaught TypeError: Cannot read property 'indexOf' of null
      at init._isAllWidths (zul.mesh.wpd:1103)
      at init._adjSpanWd (zul.mesh.wpd:1221)
      at init._calcSize (zul.mesh.wpd:1010)
      at init.onSize (zul.mesh.wpd:885)
      at init.$supers (zk.wpd:10776)
      at init.onSize (zul.sel.wpd:3005)
      at _invoke (zk.wpd:12829)
      at init.fire (zk.wpd:12812)
      at _fire (zk.wpd:12955)
      at Object.fireDown (zk.wpd:13052)
      _isAllWidths @ zul.mesh.wpd:1103
      _adjSpanWd @ zul.mesh.wpd:1221
      _calcSize @ zul.mesh.wpd:1010
      onSize @ zul.mesh.wpd:885
      $supers @ zk.wpd:10776
      onSize @ zul.sel.wpd:3005
      _invoke @ zk.wpd:12829
      fire @ zk.wpd:12812
      _fire @ zk.wpd:12955
      fireDown @ zk.wpd:13052
      fireDown @ zk.wpd:14354
      fireSized @ zk.wpd:14924
      replaceHTML @ zk.wpd:16720
      $supers @ zk.wpd:10776
      replaceHTML @ zul.mesh.wpd:746
      rerender @ zk.wpd:16783
      _rerender0 @ zk.wpd:15477
      setTimeout (async)
      _rerender @ zk.wpd:15461
      rerender @ zk.wpd:16752
      updateMesh_ @ zul.mesh.wpd:2083
      _zkf @ zul.mesh.wpd:2059
      (anonymous) @ zk.wpd:9889
      _set2 @ zk.wpd:10333
      setter.func @ zk.wpd:15882
      zk.Widget.zk.$extends.set @ zk.wpd:15910
      setAttr @ zk.wpd:21156
      doProcess @ zk.wpd:20103
      doCmdsNow @ zk.wpd:20347
      _doCmds @ zk.wpd:20603
      afterResponse @ zk.wpd:20238
      onResponseReady @ zk.wpd:20235
      XMLHttpRequest.send (async)
      ajaxSendNow @ zk.wpd:20299
      sendNow @ zk.wpd:20761
      (anonymous) @ zk.wpd:20277
      setTimeout (async)
      ajaxSend2 @ zk.wpd:20277
      ajaxSend @ zk.wpd:20271
      send @ zk.wpd:20521
      sendAU_ @ zk.wpd:17480
      fireX @ zk.wpd:17459
      doClick_ @ zk.wpd:26003
      _doEvt @ zk.wpd:19556
      (anonymous) @ zk.wpd:19750
      dispatch @ zk.wpd:5157
      elemData.handle @ zk.wpd:4828

      Expected Result

      no js error

      Debug Info

      since our javadoc allows to set width with null, there should be no javascript error

      public void setWidth(java.lang.String width)
      Sets the width. If null, the best fit is used.

      Root Cause

      w._width === undefined

      Workaround

      the attached js

            wenninghsu wenninghsu
            hawk hawk
            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 - 30 minutes
                30m