From 28bf2c834d2fb8fa03d9bf4d66e66573b926fd14 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Tue, 13 Oct 2020 10:35:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?DEC-15325=20fix:=20=E8=A7=A3=E5=86=B3click-?= =?UTF-8?q?blur=20popup=E6=8C=82=E5=9C=A8body=E4=B8=8A=E5=92=8CIE11?= =?UTF-8?q?=E5=AD=90=E5=85=83=E7=B4=A0=E8=A7=A6=E5=8F=91blur=E5=9C=BA?= =?UTF-8?q?=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 04f4d17bc..fbd96f310 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -81,7 +81,7 @@ element: this }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: [ - {el: this.combo} + { el: this.combo } ] })))); o.isDefaultInit && (this._assertPopupView()); @@ -117,7 +117,7 @@ var enterPopup = false; - function hide (e) { + function hide(e) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) { self._hideView(e); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); @@ -223,13 +223,17 @@ 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; - // } o.toggle ? self._toggle(e) : self._popupView(e); if (self.isViewVisible()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Combo.EVENT_EXPAND); + self.popupView.element.off("mouseenter." + self.getName()).on("mouseenter." + self.getName(), function (e) { + enterPopup = true; + self.popupView.element.on("mouseleave." + self.getName(), function (e) { + enterPopup = false; + self.popupView.element.off("mouseleave." + self.getName()); + }); + }); } else { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Combo.EVENT_COLLAPSE); @@ -243,15 +247,30 @@ self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) { debounce(e); try { - self.element[0].focus(); + self.element.focus(); } catch (e) { } st(e); }); + + var enterCombo = false; + self.combo.element.off("mouseenter." + self.getName()).on("mouseenter." + self.getName(), function (e) { + enterCombo = true; + self.combo.element.on("mouseleave." + self.getName(), function (e) { + enterCombo = false; + self.combo.element.off("mouseleave." + self.getName()); + }); + }); + + self.element.off("blur." + self.getName()).on("blur." + self.getName(), function (e) { if (self.isViewVisible()) { - self._hideView(e); + if (!enterCombo && !enterPopup) { + self._hideView(e); + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); + self.fireEvent(BI.Combo.EVENT_COLLAPSE); + } } st(e); }); @@ -295,7 +314,7 @@ scrolly: false, element: this.options.container || this, items: [ - {el: this.popupView} + { el: this.popupView } ] }); this._rendered = true; From 20a779a38425a5711b6a7344ec1e30ccc77b1396 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Tue, 13 Oct 2020 14:37:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20chore:=20?= =?UTF-8?q?update=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/config/fix.js | 7 ++- demo/js/fix-2.0/context.js | 10 +++-- demo/js/fix-2.0/inject.js | 87 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 demo/js/fix-2.0/inject.js diff --git a/demo/js/config/fix.js b/demo/js/config/fix.js index 8a69eaed8..6eacf396e 100644 --- a/demo/js/config/fix.js +++ b/demo/js/config/fix.js @@ -46,4 +46,9 @@ Demo.FIX_CONFIG = [{ pId: 7, text: "场景", value: "demo.fix_scene" -}]; \ No newline at end of file +}, { + id: 80, + pId: 7, + text: "inject", + value: "demo.fix_inject" +}]; diff --git a/demo/js/fix-2.0/context.js b/demo/js/fix-2.0/context.js index 475a820bb..b248b502c 100644 --- a/demo/js/fix-2.0/context.js +++ b/demo/js/fix-2.0/context.js @@ -8,6 +8,8 @@ childContext: ["context"] }); + BI.model("demo.model.context.parent_store",ParentStore) + var ChildStore = BI.inherit(Fix.Model, { context: ["context"], computed: { @@ -22,9 +24,11 @@ } }); + BI.model("demo.model.context.child_store",ChildStore) + var Child = BI.inherit(BI.Widget, { _store: function () { - return new ChildStore(); + return BI.Models.getModel("demo.model.context.child_store"); }, watch: { currContext: function (val) { @@ -53,7 +57,7 @@ var Parent = BI.inherit(BI.Widget, { _store: function () { - return new ParentStore(); + return BI.Models.getModel("demo.model.context.parent_store"); }, render: function () { var self = this; @@ -72,4 +76,4 @@ }); BI.shortcut("demo.fix_context", Parent); -}()); \ No newline at end of file +}()); diff --git a/demo/js/fix-2.0/inject.js b/demo/js/fix-2.0/inject.js new file mode 100644 index 000000000..3c7b27fcb --- /dev/null +++ b/demo/js/fix-2.0/inject.js @@ -0,0 +1,87 @@ +(function () { + var ParentStore = BI.inherit(Fix.Model, { + state: function () { + return { + context: { + one: { + key: "one.key" + } + } + }; + }, + childContext: ["context"] + }); + + BI.model("demo.model.inject.parent_store", ParentStore); + + var ChildStore = BI.inherit(Fix.Model, { + inject: ["context"], + computed: { + currContext: function () { + return this.model.context.one.key; + } + }, + actions: { + changeContext: function () { + this.model.context = { + two: { + key: "two.key" + } + }; + } + } + }); + + BI.model("demo.model.inject.child_store", ChildStore); + + var Child = BI.inherit(BI.Widget, { + _store: function () { + return BI.Models.getModel("demo.model.inject.child_store"); + }, + watch: { + currContext: function (val) { + this.button.setText(val); + } + }, + render: function () { + var self = this; + return { + type: "bi.button", + ref: function () { + self.button = this; + }, + text: this.model.currContext, + handler: function () { + self.store.changeContext(); + } + }; + }, + mounted: function () { + + } + }); + + BI.shortcut("demo.fix_inject_child", Child); + + var Parent = BI.inherit(BI.Widget, { + _store: function () { + return BI.Models.getModel("demo.model.inject.parent_store"); + }, + render: function () { + var self = this; + return { + type: "bi.absolute", + items: [{ + el: { + type: "demo.fix_inject_child" + } + }] + }; + }, + mounted: function () { + + } + }); + + BI.shortcut("demo.fix_inject", Parent); +}()); From 09a8f9453a92ebaef616c52540e874b8cf225b19 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Tue, 13 Oct 2020 14:40:24 +0800 Subject: [PATCH 3/4] =?UTF-8?q?Revert=20"DEC-15325=20fix:=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3click-blur=20popup=E6=8C=82=E5=9C=A8body=E4=B8=8A?= =?UTF-8?q?=E5=92=8CIE11=E5=AD=90=E5=85=83=E7=B4=A0=E8=A7=A6=E5=8F=91blur?= =?UTF-8?q?=E5=9C=BA=E6=99=AF"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 28bf2c834d2fb8fa03d9bf4d66e66573b926fd14. --- src/base/combination/combo.js | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index fbd96f310..04f4d17bc 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -81,7 +81,7 @@ element: this }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { items: [ - { el: this.combo } + {el: this.combo} ] })))); o.isDefaultInit && (this._assertPopupView()); @@ -117,7 +117,7 @@ var enterPopup = false; - function hide(e) { + function hide (e) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) { self._hideView(e); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); @@ -223,17 +223,13 @@ 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; + // } o.toggle ? self._toggle(e) : self._popupView(e); if (self.isViewVisible()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Combo.EVENT_EXPAND); - self.popupView.element.off("mouseenter." + self.getName()).on("mouseenter." + self.getName(), function (e) { - enterPopup = true; - self.popupView.element.on("mouseleave." + self.getName(), function (e) { - enterPopup = false; - self.popupView.element.off("mouseleave." + self.getName()); - }); - }); } else { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Combo.EVENT_COLLAPSE); @@ -247,30 +243,15 @@ self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) { debounce(e); try { - self.element.focus(); + self.element[0].focus(); } catch (e) { } st(e); }); - - var enterCombo = false; - self.combo.element.off("mouseenter." + self.getName()).on("mouseenter." + self.getName(), function (e) { - enterCombo = true; - self.combo.element.on("mouseleave." + self.getName(), function (e) { - enterCombo = false; - self.combo.element.off("mouseleave." + self.getName()); - }); - }); - - self.element.off("blur." + self.getName()).on("blur." + self.getName(), function (e) { if (self.isViewVisible()) { - if (!enterCombo && !enterPopup) { - self._hideView(e); - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); - self.fireEvent(BI.Combo.EVENT_COLLAPSE); - } + self._hideView(e); } st(e); }); @@ -314,7 +295,7 @@ scrolly: false, element: this.options.container || this, items: [ - { el: this.popupView } + {el: this.popupView} ] }); this._rendered = true; From 15c19bdf901cf8fbe63f440f77f637448fc73e0c Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Tue, 13 Oct 2020 14:52:50 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20chore:=20?= =?UTF-8?q?update=20demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/fix-2.0/inject.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/demo/js/fix-2.0/inject.js b/demo/js/fix-2.0/inject.js index 3c7b27fcb..a5734635a 100644 --- a/demo/js/fix-2.0/inject.js +++ b/demo/js/fix-2.0/inject.js @@ -9,7 +9,17 @@ } }; }, - childContext: ["context"] + childContext: ["context"], + + actions: { + changeContext: function () { + this.model.context = { + two: { + key: "two.key" + } + }; + } + } }); BI.model("demo.model.inject.parent_store", ParentStore); @@ -24,8 +34,8 @@ actions: { changeContext: function () { this.model.context = { - two: { - key: "two.key" + one: { + key: "one.changed_key" } }; } @@ -56,9 +66,6 @@ } }; }, - mounted: function () { - - } }); BI.shortcut("demo.fix_inject_child", Child); @@ -70,11 +77,19 @@ render: function () { var self = this; return { - type: "bi.absolute", + type: "bi.vertical", items: [{ el: { type: "demo.fix_inject_child" } + }, { + el: { + type: "bi.button", + text: "点击修改parent state", + handler: function () { + self.store.changeContext(); + } + } }] }; },