mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +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[]>([])
|
||||
|
||||
function closeOthers (itemIndex: number) {
|
||||
if (!props.items[itemIndex].closeOthers && props.multiple) {
|
||||
function closeOthers (currentIndex: number) {
|
||||
if (!props.items[currentIndex].closeOthers && props.multiple) {
|
||||
return
|
||||
}
|
||||
|
||||
buttonRefs.value.forEach((close, index) => {
|
||||
if (index === itemIndex) return
|
||||
const totalItems = buttonRefs.value.length
|
||||
|
||||
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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function onEnter (el: HTMLElement, done) {
|
||||
|
||||
Reference in New Issue
Block a user