Skip to content
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

Collapsing Accordion with exclusive inside Accordion with exclusive propagates to the parent #871

Open
3 tasks done
dev-idkwhoami opened this issue Dec 15, 2024 · 3 comments

Comments

@dev-idkwhoami
Copy link

Flux version

v1.0.32

Livewire version

v3.5.17

What is the problem?

When you place an accordion inside an accordion, both with the exclusive attribute, when opening a child's accordion item, the parent is closed.

Image

I don't know the details but im assuming the "close event" is not being stopped at the accordion so it propagates up to the parent accordion.

Code snippets

            <flux:accordion exclusive>

                <flux:accordion.item heading="How do i use ____ to pay ?" expanded class="space-y-6 border-b-2 border-b-zinc-200">

                    <flux:accordion exclusive class="space-y-3">

                        <flux:accordion.item heading="Paypal">
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, delectus.</p>
                        </flux:accordion.item>
                        <flux:accordion.item heading="Credit Card">
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, delectus.</p>
                        </flux:accordion.item>

                    </flux:accordion>
                </flux:accordion.item>

            </flux:accordion>

How do you expect it to work?

I would expect the accordions to work separately from each other.

Please confirm (incomplete submissions will not be addressed)

  • I have provided easy and step-by-step instructions to reproduce the bug.
  • I have provided code samples as text and NOT images.
  • I understand my bug report will be closed if I haven't met the criteria above.
@jeffchown
Copy link

jeffchown commented Dec 17, 2024

@dev-idkwhoami While I can reproduce what you describe, personally, I wouldn't nest accordions as I feel it creates a complicated UI. In your example, I would have two flux:accordion.items at the 'parent' level, one for Paypal and one for Credit Card as then the user would only have to click once to get their answer. (vs. 2 clicks into the nested structure)

@dev-idkwhoami
Copy link
Author

dev-idkwhoami commented Dec 18, 2024

The provided code sample is a VERY simplified version of my actual use case.

All that would need to be done is stop the propagation at the accordion.item's closest accordion parent element. At least it works when I do this:

        <flux:accordion exclusive>

            <flux:accordion.item heading="How do i use ____ to pay ?" expanded>

                <flux:accordion @lofi-disclosable-change.stop="" exclusive>

                    <flux:accordion.item heading="Paypal">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, delectus.</p>
                    </flux:accordion.item>
                    <flux:accordion.item heading="Credit Card">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, delectus.</p>
                    </flux:accordion.item>

                </flux:accordion>

            </flux:accordion.item>

            {{-- More Questions ... --}}
        </flux:accordion>

@jeffchown
Copy link

jeffchown commented Dec 18, 2024

@dev-idkwhoami Gotcha. Nice workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants