From 5b1bf8f3be3aaab7317beb471402201c53bb8640 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 16 Nov 2020 09:35:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?BI-74048=20fix:=20popover=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B9=9F=E5=81=9A=E4=B8=80=E4=B8=8B=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/layer/layer.popover.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/base/layer/layer.popover.js b/src/base/layer/layer.popover.js index 387d1ff4e..379ee1463 100644 --- a/src/base/layer/layer.popover.js +++ b/src/base/layer/layer.popover.js @@ -140,7 +140,7 @@ BI.Popover = BI.inherit(BI.Widget, { return BI.extend({ type: o.logic.dynamic ? "bi.vertical" : "bi.vtape", items: items, - width: size.width, + width: this._getSuitableBodyWidth(size.width), }, o.logic.dynamic ? { type: "bi.vertical", scrolly: false, @@ -166,6 +166,10 @@ BI.Popover = BI.inherit(BI.Widget, { return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight - o.headerHeight - (o.footer ? o.footerHeight : 0) - c.BODY_TGAP); }, + _getSuitableBodyWidth: function (width) { + return BI.clamp(width, 0, BI.Widget._renderEngine.createElement("body").width()); + }, + _calculateSize: function () { var o = this.options; var size = {}; From 9de2676a780c4343390107bd98a4ad5265965922 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 16 Nov 2020 10:30:52 +0800 Subject: [PATCH 2/4] comment --- src/base/layer/layer.popover.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/base/layer/layer.popover.js b/src/base/layer/layer.popover.js index 379ee1463..1a80c88fe 100644 --- a/src/base/layer/layer.popover.js +++ b/src/base/layer/layer.popover.js @@ -140,13 +140,13 @@ BI.Popover = BI.inherit(BI.Widget, { return BI.extend({ type: o.logic.dynamic ? "bi.vertical" : "bi.vtape", items: items, - width: this._getSuitableBodyWidth(size.width), + width: this._getSuitableWidth(size.width), }, o.logic.dynamic ? { type: "bi.vertical", scrolly: false, } : { type: "bi.vtape", - height: BI.clamp(size.height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight), + height: this._getSuitableHeight(size.height), }); }, @@ -166,7 +166,11 @@ BI.Popover = BI.inherit(BI.Widget, { return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight - o.headerHeight - (o.footer ? o.footerHeight : 0) - c.BODY_TGAP); }, - _getSuitableBodyWidth: function (width) { + _getSuitableHeight: function (height) { + return BI.clamp(height, 0, BI.Widget._renderEngine.createElement("body")[0].clientHeight); + }, + + _getSuitableWidth: function (width) { return BI.clamp(width, 0, BI.Widget._renderEngine.createElement("body").width()); }, From fe882291c551c16ec2064f7f32de462cab1ff695 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 16 Nov 2020 11:28:42 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=85key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/wrapper/layout.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index d56ec5344..1f572f735 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -448,7 +448,7 @@ BI.Layout = BI.inherit(BI.Widget, { this._children = {}; BI.each(newCh, function (i, child) { var node = self._getOptions(child); - var key = node.key == null ? self._getChildName(i) : node.key; + var key = node.key == null ? i : node.key; children[key]._mount(); self._children[self._getChildName(i)] = children[key]; }); @@ -466,7 +466,7 @@ BI.Layout = BI.inherit(BI.Widget, { function addNode (vnode, index) { var opt = self._getOptions(vnode); - var key = opt.key == null ? self._getChildName(index) : opt.key; + var key = opt.key == null ? index : opt.key; return children[key] = self._addElement(key, vnode); } @@ -482,7 +482,7 @@ BI.Layout = BI.inherit(BI.Widget, { var ch = vnodes[startIdx]; if (BI.isNotNull(ch)) { var node = self._getOptions(ch); - var key = node.key == null ? self._getChildName(startIdx) : node.key; + var key = node.key == null ? startIdx : node.key; delete self._children[self._getChildName(key)]; children[key]._destroy(); } From 5f020967fc5fc9a9070de657c140be7b59986a6a Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 16 Nov 2020 11:41:02 +0800 Subject: [PATCH 4/4] update --- src/core/wrapper/layout.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 1f572f735..dc3b972b6 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -399,23 +399,23 @@ BI.Layout = BI.inherit(BI.Widget, { oldEndVnode = oldCh[--oldEndIdx]; } else if (sameVnode(oldStartVnode, newStartVnode, oldStartIdx, newStartIdx)) { updated = this.patchItem(oldStartVnode, newStartVnode, oldStartIdx) || updated; - children[oldStartVnode.key == null ? this._getChildName(oldStartIdx) : oldStartVnode.key] = this._children[this._getChildName(oldStartIdx)]; + children[oldStartVnode.key == null ? oldStartIdx : oldStartVnode.key] = this._children[this._getChildName(oldStartIdx)]; oldStartVnode = oldCh[++oldStartIdx]; newStartVnode = newCh[++newStartIdx]; } else if (sameVnode(oldEndVnode, newEndVnode, oldEndIdx, newEndIdx)) { updated = this.patchItem(oldEndVnode, newEndVnode, oldEndIdx) || updated; - children[oldEndVnode.key == null ? this._getChildName(oldEndIdx) : oldEndVnode.key] = this._children[this._getChildName(oldEndIdx)]; + children[oldEndVnode.key == null ? oldEndIdx : oldEndVnode.key] = this._children[this._getChildName(oldEndIdx)]; oldEndVnode = oldCh[--oldEndIdx]; newEndVnode = newCh[--newEndIdx]; } else if (sameVnode(oldStartVnode, newEndVnode)) { updated = this.patchItem(oldStartVnode, newEndVnode, oldStartIdx) || updated; - children[oldStartVnode.key == null ? this._getChildName(oldStartIdx) : oldStartVnode.key] = this._children[this._getChildName(oldStartIdx)]; + children[oldStartVnode.key == null ? oldStartIdx : oldStartVnode.key] = this._children[this._getChildName(oldStartIdx)]; insertBefore(oldStartVnode, oldEndVnode, true); oldStartVnode = oldCh[++oldStartIdx]; newEndVnode = newCh[--newEndIdx]; } else if (sameVnode(oldEndVnode, newStartVnode)) { updated = this.patchItem(oldEndVnode, newStartVnode, oldEndIdx) || updated; - children[oldEndVnode.key == null ? this._getChildName(oldEndIdx) : oldEndVnode.key] = this._children[this._getChildName(oldEndIdx)]; + children[oldEndVnode.key == null ? oldEndIdx : oldEndVnode.key] = this._children[this._getChildName(oldEndIdx)]; insertBefore(oldEndVnode, oldStartVnode); oldEndVnode = oldCh[--oldEndIdx]; newStartVnode = newCh[++newStartIdx]; @@ -429,7 +429,7 @@ BI.Layout = BI.inherit(BI.Widget, { BI.each(oldCh, function (index, child) { if (child && sameVnode(child, newStartVnode)) { updated = self.patchItem(sameOldVnode, newStartVnode, index) || updated; - children[sameOldVnode.key == null ? self._getChildName(index) : sameOldVnode.key] = self._children[self._getChildName(index)]; + children[sameOldVnode.key == null ? index : sameOldVnode.key] = self._children[self._getChildName(index)]; oldCh[index] = undefined; insertBefore(sameOldVnode, oldStartVnode); } @@ -492,9 +492,9 @@ BI.Layout = BI.inherit(BI.Widget, { function insertBefore (insert, before, isNext, index) { insert = self._getOptions(insert); before = before && self._getOptions(before); - var insertKey = BI.isKey(insert.key) ? insert.key : self._getChildName(index); + var insertKey = BI.isKey(insert.key) ? insert.key : index; if (before && children[before.key]) { - var beforeKey = BI.isKey(before.key) ? before.key : self._getChildName(index); + var beforeKey = BI.isKey(before.key) ? before.key : index; var next; if (isNext) { next = children[beforeKey].element.next();