From 9640e2d5dd4ace95d4fd9f03af160b4329e97282 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 10 Oct 2021 14:35:52 +0300 Subject: [PATCH] Change the way collapse handles its children on opening --- js/src/collapse.js | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/js/src/collapse.js b/js/src/collapse.js index f4fa11de40..642f7e840b 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -13,7 +13,6 @@ import { reflow, typeCheckConfig } from './util/index' -import Data from './dom/data' import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' import SelectorEngine from './dom/selector-engine' @@ -77,7 +76,6 @@ class Collapse extends BaseComponent { .filter(foundElem => foundElem === this._element) if (selector !== null && filterElement.length) { - this._selector = selector this._triggerArray.push(elem) } } @@ -116,21 +114,17 @@ class Collapse extends BaseComponent { return } - let actives = [] - let activesData + let activeChildren = [] + // find active children if (this._config.parent) { - actives = this._getFirstLevelChildren(SELECTOR_ACTIVES) + activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES) + .filter(element => element !== this._element) + .map(element => Collapse.getOrCreateInstance(element, { toggle: false })) } - const container = SelectorEngine.findOne(this._selector) - if (actives.length) { - const tempActiveData = actives.find(elem => container !== elem) - activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null - - if (activesData && activesData._isTransitioning) { - return - } + if (activeChildren.length && activeChildren[0]._isTransitioning) { + return } const startEvent = EventHandler.trigger(this._element, EVENT_SHOW) @@ -138,14 +132,8 @@ class Collapse extends BaseComponent { return } - for (const elemActive of actives) { - if (container !== elemActive) { - Collapse.getOrCreateInstance(elemActive, { toggle: false }).hide() - } - - if (!activesData) { - Data.set(elemActive, DATA_KEY, null) - } + for (const activeInstance of activeChildren) { + activeInstance.hide() } const dimension = this._getDimension()