fix: inconsistent sidebar group toggle on navigation #182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR has a fix for inconsistent sidebar toggle for group items.
Previous Behaviour
After Fix
The problem
Unlike the previous problem (fixed here), this problem occurs when navigating between group items. From the buefy docs the behaviour that is intended is for only one group to be expanded at a time. This is not happening properly.
There is a peculiar collapse behaviour as seen below.
Another peculiar behaviour
Solutions
The reason such a behaviour exists is that the state of the component is managed by our code using
activeGroup
. We watch the route and change theactiveGroup
based on the current route.listmonk/frontend/src/App.vue
Lines 135 to 142 in 0f055ea
However, on expand or collapse of a group, no event is triggered. The fix after figuring this out becomes pretty straightforward.
BMenuItem
has two UI "mutations", one is routing, the other is a toggle expand and collapse (both triggered by a click event). There is an event for route already, however there is no trigger on expand or collpase.Buefy has a
onClick
handler forBMenuItem
, which looks like the followingThe
this.newActive
returns the current state of the group (whether it's expanded or collapsed) it is emitted via theupdate:active
event, which we can listen on. This PR adds that event.Depending on
update:active
is not the most elegant solution, since the event is not intended for this. The alternate is to completely override theonClick
event for this, which defeats the purpose of using the component library in the first place.Links