From 4587dd0c41913979670ec94e63df6386150c5e30 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Fri, 11 Mar 2022 14:50:18 +0100 Subject: [PATCH] Fix reactivity in mobile shares nav Update snapshot test --- .../src/components/AppBar/SharesNavigation.vue | 17 +++++++++++++---- .../__snapshots__/SharesNavigation.spec.js.snap | 12 ++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/web-app-files/src/components/AppBar/SharesNavigation.vue b/packages/web-app-files/src/components/AppBar/SharesNavigation.vue index 358cd575b84..d203c34a941 100644 --- a/packages/web-app-files/src/components/AppBar/SharesNavigation.vue +++ b/packages/web-app-files/src/components/AppBar/SharesNavigation.vue @@ -45,9 +45,9 @@ import { locationSharesWithMe, locationSharesWithOthers } from '../../router/shares' -import { useActiveLocation } from '../../composables' import { computed, getCurrentInstance, unref } from '@vue/composition-api' import { useRouter } from 'web-pkg/src/composables' +import { useActiveLocation } from '../../composables' export default { setup() { @@ -61,24 +61,33 @@ export default { routes[route.name] = router.getRoutes().find((r) => r.name === route.name) return routes }, {}) + const sharesWithMeActive = useActiveLocation(isLocationSharesActive, locationSharesWithMe.name) + const sharesWithOthersActive = useActiveLocation( + isLocationSharesActive, + locationSharesWithOthers.name + ) + const sharesViaLinkActive = useActiveLocation( + isLocationSharesActive, + locationSharesViaLink.name + ) const navItems = computed(() => [ { icon: 'share-forward', to: sharesRoutes[locationSharesWithMe.name].path, text: $gettext('Shared with me'), - active: unref(useActiveLocation(isLocationSharesActive, locationSharesWithMe.name)) + active: unref(sharesWithMeActive) }, { icon: 'reply', to: sharesRoutes[locationSharesWithOthers.name].path, text: $gettext('Shared with others'), - active: unref(useActiveLocation(isLocationSharesActive, locationSharesWithOthers.name)) + active: unref(sharesWithOthersActive) }, { icon: 'link', to: sharesRoutes[locationSharesViaLink.name].path, text: $gettext('Shared via link'), - active: unref(useActiveLocation(isLocationSharesActive, locationSharesViaLink.name)) + active: unref(sharesViaLinkActive) } ]) return { diff --git a/packages/web-app-files/tests/unit/components/AppBar/__snapshots__/SharesNavigation.spec.js.snap b/packages/web-app-files/tests/unit/components/AppBar/__snapshots__/SharesNavigation.spec.js.snap index 7b09bf8d7d4..40a4a02b00c 100644 --- a/packages/web-app-files/tests/unit/components/AppBar/__snapshots__/SharesNavigation.spec.js.snap +++ b/packages/web-app-files/tests/unit/components/AppBar/__snapshots__/SharesNavigation.spec.js.snap @@ -4,17 +4,17 @@ exports[`SharesNavigation component renders a shares navigation for both mobile