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 {