0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00

Change the way collapse handles its children on opening

This commit is contained in:
GeoSot 2021-10-10 14:35:52 +03:00 committed by XhmikosR
parent 1eea132866
commit 9640e2d5dd

View File

@ -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()