-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Accordion): add multiple
prop and close others by default
#364
Conversation
✅ Live Preview ready!
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@oritwoen is attempting to deploy a commit to the Nuxt Labs Team on Vercel. A member of the Team first needs to authorize it. |
@oritwoen, nice additions! ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! I'd rather have a multiple
prop (instead of closeOthers
) that is false
by default. When multiple
is false, only one item at a time can be open.
@Haythamasalama I corrected the types in the code. @benjamincanac Right This creates a small breaking change for users who already used I have updated the code and documentation based on the above issues. For the items objects, I left the There was also the issue of |
So far it is in Edge so we are find to change the behaviour before it becomes stable. |
@oritwoen It's ok to let There is still a timing issue with the transition when Why not to let Also, this behaviour doesn't work when overriding the button in the default slot. How can we achieve that without passing the |
I'm wondering if we can rename |
@oritwoen 1- To solve the issue with the In the <HDisclosureButton :ref="() => updateClosesRefs(close, index)" as="template" :disabled="item.disabled">
<slot :item="item" :index="index" :open="open" :close="close" :close-all="closeAll">
// .. In the <UAccordion :items="items" :ui="{ wrapper: 'flex flex-col w-full' }">
<template #default="{ item, index, open , closeAll }">
<UButton //.... @click="closeAll(index)">
I have tested it, and it works correctly. 2- It is unnecessary to add as HTMLElement in (el as HTMLElement). function onLeave (el: HTMLElement, done) {
// (el as HTMLElement).addEventListener('transitionend', done, { once: true })
el.addEventListener('transitionend', done, { once: true })
} The |
@Haythamasalama That was my point, I don't like the idea of asking users to manually assign the function themself when overriding the default slot. I'm looking for another way to achieve this! |
I've updated the behaviour with a child component that emits when the |
closeOthers
multiple
prop and close others by default
This way it's very perfect ❤️ But I still noticed a slight shift between button items, however, not with |
Indeed, I've noticed it too. This is because of |
I tried to remove |
Sorry guys but due to internet problems I couldn't work on the pull request the last few days. I had some comments/corrections but I see that the merge is already done. When I have a stable network, I'll just do additional PR in terms of performance or drafts with the thoughts that came to my mind. Thanks :) |
Resolves #362
Resolves #356
This PR adds to the
Accordion
component an additional mode of operation where you can customize the closing of panels when a specific list item is opened or global closing of panels whenever 1 list item is open.