Skip to content

Commit

Permalink
Fix double click on sidebar on smaller screens (#906)
Browse files Browse the repository at this point in the history
The problem was that on smaller screens or when resizing, v-navigation-drawer would change its value on its own, but these changes were not propagated to AppSidebar.
I also added a few missing type definitions for SidebarLinks.
  • Loading branch information
PFischbeck authored Jan 7, 2022
1 parent 76d2eec commit 2c17845
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
38 changes: 25 additions & 13 deletions frontend/components/Layout/AppSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-navigation-drawer class="d-flex flex-column d-print-none" :value="value" clipped app width="240px">
<v-navigation-drawer v-model="drawer" class="d-flex flex-column d-print-none" clipped app width="240px">
<!-- User Profile -->
<template v-if="$auth.user">
<v-list-item two-line to="/user/profile" exact>
Expand Down Expand Up @@ -124,9 +124,9 @@
</template>
</v-navigation-drawer>
</template>

<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import { computed, defineComponent, reactive, toRefs } from "@nuxtjs/composition-api";
import { SidebarLinks } from "~/types/application-types";
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
Expand Down Expand Up @@ -162,20 +162,32 @@ export default defineComponent({
default: null,
},
},
setup() {
return {};
},
data() {
return {
setup(props, context) {
// V-Model Support
const drawer = computed({
get: () => {
return props.value;
},
set: (val) => {
context.emit("input", val);
},
});
const state = reactive({
dropDowns: {},
topSelected: null,
secondarySelected: null,
bottomSelected: null,
};
topSelected: null as string[] | null,
secondarySelected: null as string[] | null,
bottomSelected: null as string[] | null,
});
return {
...toRefs(state),
drawer,
}
},
});
</script>

<style>
@media print {
.no-print {
Expand Down
6 changes: 3 additions & 3 deletions frontend/layouts/admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
:bottom-links="bottomLinks"
:user="{ data: true }"
:secondary-header="$t('user.admin')"
@input="sidebar = !sidebar"
/>

<TheSnackbar />
Expand All @@ -31,6 +30,7 @@ import { defineComponent, ref, useContext, onMounted } from "@nuxtjs/composition
import AppHeader from "@/components/Layout/AppHeader.vue";
import AppSidebar from "@/components/Layout/AppSidebar.vue";
import TheSnackbar from "~/components/Layout/TheSnackbar.vue";
import { SidebarLinks } from "~/types/application-types";
export default defineComponent({
components: { AppHeader, AppSidebar, TheSnackbar },
Expand All @@ -45,7 +45,7 @@ export default defineComponent({
sidebar.value = !$vuetify.breakpoint.md;
});
const topLinks = [
const topLinks: SidebarLinks = [
{
icon: $globals.icons.viewDashboard,
to: "/admin/dashboard",
Expand Down Expand Up @@ -105,7 +105,7 @@ export default defineComponent({
},
];
const bottomLinks = [
const bottomLinks: SidebarLinks = [
{
icon: $globals.icons.heart,
title: i18n.t("about.support"),
Expand Down
4 changes: 3 additions & 1 deletion frontend/types/application-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { TranslateResult } from "vue-i18n";

export interface SideBarLink {
icon: string;
to: string;
to?: string;
href?: string;
title: TranslateResult;
children?: SideBarLink[];
}

export type SidebarLinks = Array<SideBarLink>;

0 comments on commit 2c17845

Please sign in to comment.