Skip to content

Commit

Permalink
for "panel activities" only toggle sideBar if route !== activity.to
Browse files Browse the repository at this point in the history
Alter the way the `ActivityBar` treats "panel activities";
i.e.: activities that have a sideBar associated,
so that if the sidebar is active but the current route isn't `activity.to`, then keep sidebar active and
just change route.

Also, if `activity.to` is current route, always keep activity's `is-active` prop = true regardless of sidebar for the activity being active or not.
  • Loading branch information
ahmedhamidawan committed Jan 17, 2024
1 parent 6f9f122 commit a98be64
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions client/src/components/ActivityBar/ActivityBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const dragItem: Ref<Activity | null> = ref(null);
const isDragging = ref(false);
/**
* Checks if the route of an activitiy is currently being visited and panels are collapsed
* Checks if the route of an activity is currently being visited and panels are collapsed
*/
function isActiveRoute(activityTo: string) {
return route.path === activityTo && isActiveSideBar("");
Expand All @@ -63,6 +63,13 @@ function isActiveSideBar(menuKey: string) {
return userStore.toggledSideBar === menuKey;
}
/**
* Checks if an activity that has a panel should have the `is-active` prop
*/
function panelActivityIsActive(activity: Activity) {
return isActiveSideBar(activity.id) || (activity.to !== null && isActiveRoute(activity.to));
}
/**
* Evaluates the drop data and keeps track of the drop area
*/
Expand Down Expand Up @@ -110,7 +117,12 @@ function onDragOver(evt: MouseEvent) {
/**
* Tracks the state of activities which expand or collapse the sidepanel
*/
function onToggleSidebar(toggle: string) {
function onToggleSidebar(toggle: string, to: string | null = null) {
// if an activity's dedicated panel/sideBar is already active
// but the route is different, don't collapse
if (toggle && to && !(route.path === to) && isActiveSideBar(toggle)) {
return;
}
userStore.toggleSideBar(toggle);
}
Expand Down Expand Up @@ -172,11 +184,11 @@ function toggleContextMenu(evt: MouseEvent) {
:id="`activity-${activity.id}`"
:key="activity.id"
:icon="activity.icon"
:is-active="isActiveSideBar(activity.id)"
:is-active="panelActivityIsActive(activity)"
:title="activity.title"
:tooltip="activity.tooltip"
:to="activity.to"
@click="onToggleSidebar(activity.id)" />
@click="onToggleSidebar(activity.id, activity.to)" />
<ActivityItem
v-else-if="activity.to"
:id="`activity-${activity.id}`"
Expand Down

0 comments on commit a98be64

Please sign in to comment.