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

fix(components/accordion): allow opened panel to be closed #684

Closed

Conversation

mufasubhai
Copy link
Contributor

Description

setOpen function didn't allow for current value to be removed if the item being clicked on was already open. As a result, it was not possible to close an accordion drawer by toggling it.

Added toggleOpen function to set out of range value for open if the current target was already open.

Fixes #618

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Please document the breaking changes if suitable.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A: tested functionality locally.
  • Test B: ran test suite to confirm no breaking changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@codecov
Copy link

codecov bot commented Apr 2, 2023

Codecov Report

Patch coverage: 90.00% and project coverage change: -0.02 ⚠️

Comparison is base (3ab9108) 99.42% compared to head (fe8d162) 99.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #684      +/-   ##
==========================================
- Coverage   99.42%   99.41%   -0.02%     
==========================================
  Files         130      130              
  Lines        6448     6457       +9     
  Branches      485      487       +2     
==========================================
+ Hits         6411     6419       +8     
- Misses         37       38       +1     
Impacted Files Coverage Δ
src/lib/components/Accordion/Accordion.tsx 98.83% <90.00%> (-1.17%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@rluders rluders left a comment

Choose a reason for hiding this comment

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

@mufasubhai seems to work. I would like however to see some unit tests for it. :)

@mufasubhai
Copy link
Contributor Author

Sounds good @rluders. I'll add some over the next couple days. Thanks for the feedback!

@rluders
Copy link
Collaborator

rluders commented Apr 17, 2023

Sounds good @rluders. I'll add some over the next couple days. Thanks for the feedback!

still missing the unit tests that you promised me. 💔 🤣

@rluders rluders changed the title Bug/fix accordion content close fix(components/accordion): allow opened panel to be closed Apr 17, 2023
@mufasubhai
Copy link
Contributor Author

Oh jeez. It's been a while, hasn't it? My apologies. I'll try and update these today or tomorrow!

mufasubhai pushed a commit to mufasubhai/flowbite-react that referenced this pull request Apr 19, 2023
@mufasubhai
Copy link
Contributor Author

recreated under pull request 705 (re-synced fork prior to creating the new PR.) Let me know if there are any other changes you need made. Sorry for the delay!

#705

@mufasubhai mufasubhai closed this Apr 19, 2023
rluders pushed a commit that referenced this pull request Apr 19, 2023
… accordion tests (#705)

* fix(accordion.tsx): fixed bug where Accordion.Content would not close after being opened

Accordion content can now be closed and opened leaving all items collapsed.

#618

* style(accordion.tsx): update spacing after adding toggleOpen function

* test(accordion.spec.tsx): add tests for accordion click to toggle

#684

* style(accordion.spec): prettier

* style(accordion.tsx): change conditional to ternary for toggleOpen

* style(accordion.tsx): prettier update for cloneElement format

---------

Co-authored-by: Adrian Apodaca <[email protected]>
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

Successfully merging this pull request may close these issues.

<Accordion.Content>s can't be closed once expanded
2 participants