From f2ccd1be0fba58a4931e47217fd5a5e7b192ca85 Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 21 Dec 2022 17:51:54 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-87371=20fix:=20=E3=80=90BI6.0?= =?UTF-8?q?=E3=80=91=E3=80=90=E7=9B=AE=E5=BD=95=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A6=96=E9=A1=B5=E3=80=91=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=97=B6=E6=A8=A1=E6=9D=BF=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E4=B8=8B=E6=8B=89=E6=A1=86=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 003571b29..2a7a0d8d8 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -214,7 +214,15 @@ }, }, } : this.combo; - var positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock(BI.isNull(o.container) ? this.element[0] : BI.Widget._renderEngine.createElement(BI.isFunction(o.container) ? o.container() : o.container)[0]); + + var positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock( + BI.isNull(o.container) + ? this.element[0] + : BI.isWidget(o.container) + ? o.container.element[0] + : BI.Widget._renderEngine.createElement(BI.isFunction(o.container) ? o.container() : o.container)[0] + ); + switch (o.direction) { case "bottom": case "bottom,right": From caf3dde39d0b360fc4f54dfd3096bf88743b7e88 Mon Sep 17 00:00:00 2001 From: zsmj Date: Thu, 22 Dec 2022 14:54:59 +0800 Subject: [PATCH 2/6] =?UTF-8?q?BI-119217=20fix:=20=E3=80=906.0.6=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E7=AD=89=E6=AF=94=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?-=E9=AB=98=E6=B8=85=E5=B1=8F-=E5=AE=BD=E5=BA=A6=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E9=A2=84=E8=A7=88=EF=BC=8C=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A0=91=E6=9F=A5=E7=9C=8B=E5=B7=B2=E9=80=89=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 要考虑相对定位元素发生滚动的场景 --- src/base/combination/combo.js | 4 +-- src/core/platform/web/dom.js | 59 +++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 2a7a0d8d8..75c45a4fe 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -310,8 +310,8 @@ var scaleX = positonedRect.width / positionRelativeElement.offsetWidth; var scaleY = positonedRect.height / positionRelativeElement.offsetHeight; - p.top && (p.top = Math.round(p.top / scaleY)); - p.left && (p.left = Math.round(p.left / scaleX)); + p.top && (p.top = Math.round(p.top / scaleY + positionRelativeElement.scrollTop)); + p.left && (p.left = Math.round(p.left / scaleX + positionRelativeElement.scrollLeft)); p.adaptHeight && (p.adaptHeight = Math.round(p.adaptHeight / scaleY)); } diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index 7d6ac59ea..ef1989c8a 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -239,13 +239,15 @@ }, isRightSpaceLarger: function (combo) { - var windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); - return windowBounds.width - combo.element.offset().left - combo.element.bounds().width >= combo.element.offset().left; + var comboBounds = combo.element[0].getBoundingClientRect(), + viewportBounds = document.documentElement.getBoundingClientRect(); + return viewportBounds.width - comboBounds.right >= comboBounds.left; }, isBottomSpaceLarger: function (combo) { - var windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); - return windowBounds.height - combo.element.offset().top - combo.element.bounds().height >= combo.element.offset().top; + var comboBounds = combo.element[0].getBoundingClientRect(), + viewportBounds = document.documentElement.getBoundingClientRect(); + return viewportBounds.height - comboBounds.bottom >= comboBounds.top; }, _getLeftAlignPosition: function (combo, popup, extraWidth, container) { @@ -279,9 +281,9 @@ }; }, - getLeftAdaptPosition: function (combo, popup, extraWidth) { - if (BI.DOM.isLeftSpaceEnough(combo, popup, extraWidth)) { - return BI.DOM.getLeftPosition(combo, popup, extraWidth); + getLeftAdaptPosition: function (combo, popup, extraWidth, container) { + if (BI.DOM.isLeftSpaceEnough(combo, popup, extraWidth, container)) { + return BI.DOM.getLeftPosition(combo, popup, extraWidth, container); } return { left: 0 @@ -312,12 +314,12 @@ }; }, - getRightAdaptPosition: function (combo, popup, extraWidth) { - if (BI.DOM.isRightSpaceEnough(combo, popup, extraWidth)) { - return BI.DOM.getRightPosition(combo, popup, extraWidth); + getRightAdaptPosition: function (combo, popup, extraWidth, container) { + if (BI.DOM.isRightSpaceEnough(combo, popup, extraWidth, container)) { + return BI.DOM.getRightPosition(combo, popup, extraWidth, container); } return { - left: BI.Widget._renderEngine.createElement("body").bounds().width - popup.element.bounds().width + left: document.documentElement.getBoundingClientRect().width - popup.element[0].getBoundingClientRect().width - container.getBoundingClientRect().left }; }, @@ -355,26 +357,28 @@ }; }, - getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { - var popupBounds = popup.element.bounds(), - windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); + getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight, positionRelativeElement) { + var comboBounds = combo.element[0].getBoundingClientRect(), + popupBounds = popup.element[0].getBoundingClientRect(), + positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(), + viewportBounds = document.documentElement.getBoundingClientRect(); if (BI.DOM.isTopSpaceEnough(combo, popup, extraHeight)) { return BI.DOM.getTopPosition(combo, popup, extraHeight); } if (needAdaptHeight) { return { - top: 0, - adaptHeight: combo.element.offset().top - extraHeight + top: 0 - positionRelativeElementRect.top, + adaptHeight: comboBounds.top - extraHeight }; } - if (popupBounds.height + extraHeight > windowBounds.height) { + if (popupBounds.height + extraHeight > viewportBounds.height) { return { - top: 0, - adaptHeight: windowBounds.height - extraHeight + top: 0 - positionRelativeElementRect.top, + adaptHeight: viewportBounds.height - extraHeight }; } return { - top: 0 + top: 0 - positionRelativeElementRect.top }; }, @@ -413,7 +417,8 @@ }, getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { - var comboBounds = combo.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(), + var comboBounds = combo.element[0].getBoundingClientRect(), + popupBounds = popup.element[0].getBoundingClientRect(), windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) { return BI.DOM.getBottomPosition(combo, popup, extraHeight); @@ -638,10 +643,10 @@ case "left": case "right": if (BI.DOM.isRightSpaceLarger(combo)) { - left = BI.DOM.getRightAdaptPosition(combo, popup, extraWidth).left; + left = BI.DOM.getRightAdaptPosition(combo, popup, extraWidth, container).left; firstDir = "right"; } else { - left = BI.DOM.getLeftAdaptPosition(combo, popup, extraWidth).left; + left = BI.DOM.getLeftAdaptPosition(combo, popup, extraWidth, container).left; firstDir = "left"; } if (topBottom[0] === "bottom") { @@ -656,19 +661,19 @@ return pos; default : if (BI.DOM.isBottomSpaceLarger(combo)) { - top = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight).top; + top = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top; firstDir = "bottom"; } else { - top = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight).top; + top = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top; firstDir = "top"; } if (leftRight[0] === "right") { - pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth); + pos = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth, container); pos.top = top; pos.dir = firstDir + "," + pos.dir; return pos; } - pos = BI.DOM.getRightAlignPosition(combo, popup, extraWidth); + pos = BI.DOM.getRightAlignPosition(combo, popup, extraWidth, container); pos.top = top; pos.dir = firstDir + "," + pos.dir; return pos; From 287c609f6cd1f7954fbf5317ceb2ee6fa54991c0 Mon Sep 17 00:00:00 2001 From: Claire <1119518763@qq.com> Date: Thu, 22 Dec 2022 16:27:48 +0800 Subject: [PATCH 3/6] =?UTF-8?q?BI-119112=20fix:editor=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89error=20bubble=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/editor/editor.js | 2 +- typescript/base/single/editor/editor.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index c0a77c9f6..098a0c543 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -276,7 +276,7 @@ BI.Editor = BI.inherit(BI.Single, { } if (!this.disabledError && BI.isKey(errorText)) { BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, { - adjustYOffset: o.simple ? 1 : 2, + adjustYOffset: BI.isKey(o.adjustYOffset) ? o.adjustYOffset : (o.simple ? 1 : 2), }); this._checkToolTip(); } diff --git a/typescript/base/single/editor/editor.ts b/typescript/base/single/editor/editor.ts index 2ac35a470..19f07aa0f 100644 --- a/typescript/base/single/editor/editor.ts +++ b/typescript/base/single/editor/editor.ts @@ -11,6 +11,7 @@ export declare class Editor extends Single { watermark?: string; errorText?: string | ((v: string) => string); autocomplete?: string; + adjustYOffset?: number; } & Single['props'] static EVENT_CHANGE: string; From 5b1f652ba3f749a6b1d64c42c5087a5cfe2dfbb8 Mon Sep 17 00:00:00 2001 From: Claire <1119518763@qq.com> Date: Thu, 22 Dec 2022 16:43:23 +0800 Subject: [PATCH 4/6] =?UTF-8?q?Revert=20"BI-119112=20fix:editor=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E8=87=AA=E5=AE=9A=E4=B9=89error=20bubble=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 287c609f6cd1f7954fbf5317ceb2ee6fa54991c0. --- src/base/single/editor/editor.js | 2 +- typescript/base/single/editor/editor.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 098a0c543..c0a77c9f6 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -276,7 +276,7 @@ BI.Editor = BI.inherit(BI.Single, { } if (!this.disabledError && BI.isKey(errorText)) { BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, { - adjustYOffset: BI.isKey(o.adjustYOffset) ? o.adjustYOffset : (o.simple ? 1 : 2), + adjustYOffset: o.simple ? 1 : 2, }); this._checkToolTip(); } diff --git a/typescript/base/single/editor/editor.ts b/typescript/base/single/editor/editor.ts index 19f07aa0f..2ac35a470 100644 --- a/typescript/base/single/editor/editor.ts +++ b/typescript/base/single/editor/editor.ts @@ -11,7 +11,6 @@ export declare class Editor extends Single { watermark?: string; errorText?: string | ((v: string) => string); autocomplete?: string; - adjustYOffset?: number; } & Single['props'] static EVENT_CHANGE: string; From db70951e38bcac0824de17efe8e3427eaa3a7c4f Mon Sep 17 00:00:00 2001 From: Claire <1119518763@qq.com> Date: Thu, 22 Dec 2022 16:44:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?BI-119112=20fix:editor=E5=BC=B9=E5=87=BAerr?= =?UTF-8?q?orbubble=E4=BD=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/controller/controller.bubbles.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/controller/controller.bubbles.js b/src/core/controller/controller.bubbles.js index 6c679b1e9..fc736a094 100644 --- a/src/core/controller/controller.bubbles.js +++ b/src/core/controller/controller.bubbles.js @@ -71,10 +71,7 @@ BI.BubblesController = BI.inherit(BI.Controller, { { name: "preventOverflow", enabled: false - }, { - name: "flip", - enabled: false - }, + } ] }); return this; From 25117de9d3b55461b3fe0f2cdc37356ffcc12b0c Mon Sep 17 00:00:00 2001 From: zsmj Date: Fri, 23 Dec 2022 10:39:02 +0800 Subject: [PATCH 6/6] =?UTF-8?q?BI-119128=20fix:=20=E3=80=90=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E8=BF=AD=E4=BB=A3=E5=8F=91=E6=95=A3=E3=80=91?= =?UTF-8?q?=E5=B0=8F=E5=B1=8F=E7=BC=96=E8=BE=91=EF=BC=8C=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E9=80=82=E5=BA=94+=E8=87=AA=E5=AE=9A=E4=B9=89=EF=BC=881366*449?= =?UTF-8?q?=EF=BC=89=EF=BC=8C=E7=9B=B4=E6=8E=A5=E9=A2=84=E8=A7=88=EF=BC=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=8E=A7=E4=BB=B6=E4=B8=8B=E6=8B=89=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E5=81=8F=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上下空间都不够的时候场景。 另外高度自适应fixed元素导致滚动问题还需探索一下 --- src/core/platform/web/dom.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index ef1989c8a..945aa359a 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -416,27 +416,28 @@ }; }, - getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { + getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight, positionRelativeElement) { var comboBounds = combo.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(), - windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); + viewportBounds = document.documentElement.getBoundingClientRect(), + positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(); if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) { - return BI.DOM.getBottomPosition(combo, popup, extraHeight); + return BI.DOM.getBottomPosition(combo, popup, extraHeight, positionRelativeElement); } if (needAdaptHeight) { return { - top: comboBounds.top + comboBounds.height + extraHeight, - adaptHeight: windowBounds.height - comboBounds.top - comboBounds.height - extraHeight + top: comboBounds.top + comboBounds.height + extraHeight - positionRelativeElementRect.top, + adaptHeight: viewportBounds.height - comboBounds.top - comboBounds.height - extraHeight }; } - if (popupBounds.height + extraHeight > windowBounds.height) { + if (popupBounds.height + extraHeight > viewportBounds.height) { return { - top: extraHeight, - adaptHeight: windowBounds.height - extraHeight + top: extraHeight - positionRelativeElementRect.top, + adaptHeight: viewportBounds.height - extraHeight }; } return { - top: windowBounds.height - popupBounds.height - extraHeight + top: viewportBounds.height - popupBounds.height - extraHeight - positionRelativeElementRect.top }; },