From 57ca936991aa83cb7c598d4935e9c799df2a4206 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 30 Sep 2020 16:52:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0focus=E8=A7=A6=E5=8F=91combo?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 49 +++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 62dde79f8d..03f42e9390 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()];