From c09ea7d0ee7ff71308c00395266b40234ba4966d Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 17 Oct 2022 10:28:14 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20combo=E6=98=BE=E9=9A=90=E8=A7=84?= =?UTF-8?q?=E5=88=99=E9=87=8D=E6=9E=84=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 5 +++++ src/core/4.widget.js | 12 ++++++++---- src/less/base/combo/combo.less | 6 +++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 7abbf77eb..8d2849ad6 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -48,6 +48,11 @@ }); }, + // 复写visual相关代码,让其通过class实现显隐藏 + __setElementVisible: function (visible) { + this.element[visible ? "removeClass" : "addClass"]("bi-combo-hidden"); + }, + render: function () { var self = this, o = this.options; this._initCombo(); diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 5af118dd5..49c1238cc 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -308,7 +308,7 @@ }) : o.invisible; if (invisible) { // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 - this.element.css("display", "none"); + this.__setElementVisible(false); } } }, @@ -513,13 +513,17 @@ } }, + __setElementVisible: function (visible) { + this.element.css("display", visible ? "" : "none"); + }, + _innerSetVisible: function (visible) { var self = this, o = this.options; var lastVisible = !o.invisible; this._setVisible(visible); if (visible === true) { // 用this.element.show()会把display属性改成block - this.element.css("display", ""); + this.__setElementVisible(true); this._mount(); if (o.animation && !lastVisible) { this.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active").addClass(o.animation + "-enter"); @@ -552,10 +556,10 @@ } this._animationDuring = setTimeout(function () { self.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active"); - self.element.css("display", "none"); + self.__setElementVisible(false); }, o.animationDuring); } else { - this.element.css("display", "none"); + this.__setElementVisible(false); } } }, diff --git a/src/less/base/combo/combo.less b/src/less/base/combo/combo.less index 206953d4b..3ebed47bc 100644 --- a/src/less/base/combo/combo.less +++ b/src/less/base/combo/combo.less @@ -12,9 +12,6 @@ } &.bi-combo-popup { - display: block !important; - visibility: visible !important; - & > .bi-trigger { & .bi-trigger-icon-button { & .x-icon { @@ -24,6 +21,9 @@ } } } + &.bi-combo-hidden:not(.bi-combo-popup) { + display: none !important; + } &.bi-combo-popup, &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom {