mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 12:17:54 +01:00
fix(Accordion): close other items in circular order (#735)
This commit is contained in:
committed by
GitHub
parent
d088d8a7b8
commit
6887f732ee
@@ -100,16 +100,21 @@ export default defineComponent({
|
|||||||
|
|
||||||
const buttonRefs = ref<Function[]>([])
|
const buttonRefs = ref<Function[]>([])
|
||||||
|
|
||||||
function closeOthers (itemIndex: number) {
|
function closeOthers (currentIndex: number) {
|
||||||
if (!props.items[itemIndex].closeOthers && props.multiple) {
|
if (!props.items[currentIndex].closeOthers && props.multiple) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonRefs.value.forEach((close, index) => {
|
const totalItems = buttonRefs.value.length
|
||||||
if (index === itemIndex) return
|
|
||||||
|
|
||||||
|
const order = Array.from({ length: totalItems }, (_, i) => (currentIndex + i) % totalItems)
|
||||||
|
.filter(index => index !== currentIndex)
|
||||||
|
.reverse()
|
||||||
|
|
||||||
|
for (const index of order) {
|
||||||
|
const close = buttonRefs.value[index]
|
||||||
close()
|
close()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEnter (el: HTMLElement, done) {
|
function onEnter (el: HTMLElement, done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user