diff --git a/changelog.md b/changelog.md index 43a9a70ce..be8d9b9a7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-09) +- combo增加focus作为触发条件功能 - allCountPager支持是否显示总行数 - 修复区间滑块setEnable(false)滑块不灰化的问题 - 修复同步复选下拉框系列setValue所有值后触发器不显示全选的问题 diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 62dde79f8..03f42e939 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -9,6 +9,9 @@ var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-combo" + (BI.isIE() ? " hack" : ""), + attributes: { + tabIndex: 0 + }, trigger: "click", toggle: true, direction: "bottom", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right||right,innerRight||right,innerLeft||innerRight||innerLeft @@ -216,6 +219,44 @@ } }); break; + case "focus": + var debounce = BI.debounce(function (e) { + if (self.combo.element.__isMouseInBounds__(e)) { + if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) { + // if (!o.toggle && self.isViewVisible()) { + // return; + // } + self._popupView(e); + if (self.isViewVisible()) { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); + self.fireEvent(BI.Combo.EVENT_EXPAND); + } else { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); + self.fireEvent(BI.Combo.EVENT_COLLAPSE); + } + } + } + }, BI.EVENT_RESPONSE_TIME, { + "leading": true, + "trailing": false + }); + self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) { + try { + self.element[0].focus(); + } catch (e) { + + } + st(e); + }); + self.element.off("focus." + self.getName()).on("focus." + self.getName(), function (e) { + debounce(e); + st(e); + }); + self.element.off("blur." + self.getName()).on("blur." + self.getName(), function (e) { + self._hideView(e); + st(e); + }); + break; } }); }, @@ -528,11 +569,15 @@ }, destroyed: function () { - BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()) + BI.Widget._renderEngine.createElement(document) + .unbind("click." + this.getName()) + .unbind("mousedown." + this.getName()) .unbind("mousewheel." + this.getName()) .unbind("mouseenter." + this.getName()) .unbind("mousemove." + this.getName()) - .unbind("mouseleave." + this.getName()); + .unbind("mouseleave." + this.getName()) + .unbind("focus." + this.getName()) + .unbind("blur." + this.getName()); BI.Resizers.remove(this.getName()); this.popupView && this.popupView._destroy(); delete needHideWhenAnotherComboOpen[this.getName()];