-
Bug
-
Resolution: Fixed
-
Normal
-
6.5.8.1, 9.0.0, 8.6.4
-
Security Level: Jimmy
-
ZK 9.5.0 S1
-
None
Steps to Reproduce
<zk> <button id="btn" label="render tabbox"/> <div fulfill="btn.onClick"> <tabbox> <tabs> <tab label="tab1"/> <tab label="tab2"/> </tabs> <tabpanels> <tabpanel>panel1</tabpanel> <tabpanel> <textbox value="my value" onCreate="self.setSelectionRange(0, 2);"/> </tabpanel> </tabpanels> </tabbox> </div> </zk>
click the button
Current Result
JS error
zk.wpd:13982 Uncaught TypeError: Cannot read property 'value' of undefined at zjq.setSelectionRange (zk.wpd:13982) at init.select (zul.inp.wpd:330) at init.select (combobox-tabbox.zul:29) at Object.select (zk.wpd:27423) at doProcess (zk.wpd:25707) at doCmdsNow (zk.wpd:25807) at Object._doCmds (zk.wpd:26175) at mtAU0 (zk.wpd:24818) at mtAU (zk.wpd:24812) at doEnd (zk.wpd:24199)
Expected Result
no error
(ignore the text selection for non-rendered widgets - they can't be focussed anyway unless rendered)
Debug Information
tabbox has client render on demand enabled by default and the widget tries to select text inside the textbox' dom input element, which is not yet rendered
this also affects other InputWidgets such e.g. combobox
Workaround
1) disable client render on demand for the tabbox
<tabbox> <custom-attributes org.zkoss.zul.client.rod="false"/> ... </tabbox>
2) it #1 is too inefficient patch the InputWidget.select() function
zk.afterLoad('zul.inp', function() { var xInputWidget = {}; zk.override(zul.inp.InputWidget.prototype, xInputWidget, { select : function() { if(!this.getInputNode()) { return; } return xInputWidget.select.apply(this, arguments); } });//zk.override });//zk.afterLoad