avo
avo copied to clipboard
Fix sidebar default collapsed state
Description
The deafault collapsed option for menu sections was not working. The default state is correctly set, but incorrectly read in the Stimulus controller, the bug was introduced in #941.
Basically, on the first load (and if the user never interacted with the collapse feature) the this.userState will return null, because there is no such key in the local storage. this.userState === 'collapsed' will always return false if the user never toggled the collapse feature, making the default option useless.
The fix is using the defaultState if userState is unefined/null.
Checklist:
- [x] 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
- [ ] I have added tests that prove my fix is effective or that my feature works
Manual review steps
- Create a section with
collapsable: true, collapsed: true - Delete local storage (clean cookies) to ensure there are no user preferences overriding the default
- Check if the section appears collapsed.
Code Climate has analyzed commit 2b1efb63 and detected 0 issues on this pull request.
View more on Code Climate.
Thanks for the fix!
Codecov Report
Merging #1127 (2b1efb6) into main (90cc721) will increase coverage by
0.20%. The diff coverage is88.48%.
@@ Coverage Diff @@
## main #1127 +/- ##
==========================================
+ Coverage 94.08% 94.29% +0.20%
==========================================
Files 430 543 +113
Lines 7861 10779 +2918
==========================================
+ Hits 7396 10164 +2768
- Misses 465 615 +150
| Impacted Files | Coverage Δ | |
|---|---|---|
| .../avo/fields/common/single_file_viewer_component.rb | 40.90% <0.00%> (ø) |
|
| app/controllers/avo/private_controller.rb | 80.00% <0.00%> (-20.00%) |
:arrow_down: |
| lib/avo/configuration.rb | 54.16% <44.44%> (-36.26%) |
:arrow_down: |
| app/controllers/avo/debug_controller.rb | 46.15% <46.15%> (ø) |
|
| app/controllers/avo/actions_controller.rb | 71.73% <57.14%> (-3.27%) |
:arrow_down: |
| lib/avo/app.rb | 75.25% <60.78%> (-15.66%) |
:arrow_down: |
| app/components/avo/sidebar_component.rb | 75.00% <66.66%> (-25.00%) |
:arrow_down: |
| lib/avo/base_action.rb | 80.39% <66.66%> (-1.06%) |
:arrow_down: |
| app/controllers/avo/home_controller.rb | 64.28% <75.00%> (+0.64%) |
:arrow_up: |
| lib/avo/concerns/has_editable_controls.rb | 75.00% <75.00%> (ø) |
|
| ... and 302 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.