Skip to content

Commit

Permalink
fix(Accordion): close other items in circular order (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haythamasalama committed Sep 24, 2023
1 parent d088d8a commit 6887f73
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/runtime/components/elements/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

1 comment on commit 6887f73

@vercel
Copy link

@vercel vercel bot commented on 6887f73 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-nuxt-js.vercel.app
ui-git-dev-nuxt-js.vercel.app
ui.nuxt.com

Please sign in to comment.