-
Bug
-
Resolution: Fixed
-
Normal
-
7.0.5, 7.0.5.2
-
None
-
Security Level: Jimmy
-
None
-
None
Steps to reproduce
- run the attached zul and view model
- type a non-existed item in the chosenbox, e.g. "bbb" then press enter.
Actual result
Javascript error is thrown:
Uncaught TypeError: Cannot read property 'length' of undefined zjq.setSelectionRange @ zk.wpd:12083 _rsFocus @ zk.wpd:14963 zk.Widget.zk.$extends.replaceWidget @ zk.wpd:15837 zAu.cmd1.outer.w @ zk.wpd:20278 mtAU @ zk.wpd:18520 zk.copy.zkx @ zk.wpd:18680 zk.copy.zkx_ @ zk.wpd:18696 zAu.cmd1.outer @ zk.wpd:20276 doProcess @ zk.wpd:19292 doCmdsNow @ zk.wpd:19532 zAu._doCmds @ zk.wpd:19780 afterResponse @ zk.wpd:19424 onResponseReady @ zk.wpd:19421
Workaround
<script type="text/javascript" defer="true"><![CDATA[ var _xChosenbox = {}; zk.override(zkmax.inp.Chosenbox.prototype, _xChosenbox, { bind_: function() { _xChosenbox.bind_.apply(this, arguments); zWatch.listen({onResponse: this}); }, unbind_: function() { zWatch.unlisten({onResponse: this}); _xChosenbox.unbind_.apply(this, arguments); }, _doEnterPressed: function () { _xChosenbox._doEnterPressed.apply(this, arguments); this._shallRestoreFocus = zk.currentFocus == this; zk.currentFocus = null; }, replaceWidget: function(newwgt) { if (this._shallRestoreFocus) { newwgt._shallRestoreFocus = true; } _xChosenbox.replaceWidget.apply(this, arguments); }, onResponse: function() { console.log('onResponse', this._shallRestoreFocus); if (this._shallRestoreFocus) this.$n('inp').focus(); } }); ]]></script>