-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Later
-
None
-
Affects Version/s: 9.6.1
-
Component/s: None
-
None
-
None
Steps to Reproduce
<zk> <zscript> ListModel model = new ListModelArray(new String[] { "North America", "South America", "Europe", "Asia", "Africa", "Oceania", "Antarctica" }); </zscript> <searchbox id="sb" model="${model}" placeholder="An unknown place" autoclose="true"> <template name="model"> <html><![CDATA[ <i class="z-icon-globe"></i> ${each} ]]></html> </template> </searchbox> </zk>
2. select "North America" twice
Current Result
the "North America" is not selected
Expected Result
the "North America" is selected
Debug Information
1. in single selection mode, searchbox works like a drop-down. A dropdown doesn't de-select an item when selecting the same item again. This is a very common behavior among dropdowns on the web. The searchbox should behave in the most common way.
Workaround
zk.afterLoad('zkmax.inp', function() { var exWidget = {}; zk.override(zkmax.inp.Searchbox.prototype, exWidget, { _doSelectItem: function(item, bulk) { var $item = jq(item), selectedClass = this.$s('selected'), selected = $item.hasClass(selectedClass); if (!this._multiple && selected){ return; //select the current selected item, keep selected, do nothing } exWidget._doSelectItem.apply(this, arguments); }, }); });