The Vuetify navigation drawer seems to have a quirk where it only closes after an item

I am brand new to Vue and struggling to figure out why my vue v-navigation-drawer is not working properly. It is located in app-root.vue and was initially closing when clicking on a drawer item, but now requires two clicks to close.

After the first click, it navigates to the page and only closes the drawer with the second click. Interestingly, if I'm already on the page, a single click will close it.

I have checked the debugger for errors but did not find any.

Below is the code for my drawer and script:

export default {
  data() {
    return {
      drawer: false,
    }
  },
  computed: {
    isPageLoading: {
      get() {
        return this.$store.state.appRoot.isPageLoading
      },
      set(value) {
        this.$store.commit('appRoot/isPageLoadingUpdate', value)
      }
    },
  }
}
<template>
    <div id="app">
        <v-app id="inspire">
            <v-navigation-drawer fixed temporary disable-resize-watcher v-model="drawer" app>
                <v-subheader class="mt-3 grey--text text--darken-1">ENTRY</v-subheader>
                <v-list dense>
                    <v-list-tile @click="drawer = !drawer" to="/entry/records">
                        <v-list-tile-content>
                            <v-list-tile-title>Records</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/coworkers">
                        <v-list-tile-content>
                            <v-list-tile-title>Coworkers</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/defendants">
                        <v-list-tile-content>
                            <v-list-tile-title>Defendants</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/documentjobs">
                        <v-list-tile-content>
                            <v-list-tile-title>Document Jobs</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/jobsites">
                        <v-list-tile-content>
                            <v-list-tile-title>Jobsites</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/locations">
                        <v-list-tile-content>
                            <v-list-tile-title>Locations</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/products">
                        <v-list-tile-content>
                            <v-list-tile-title>Products</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = 

!drawer" to="/entry/ships">
                        <v-list-tile-content>
                            <v-list-tile-title>Ships</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/sources">
                        <v-list-tile-content>
                            <v-list-tile-title>Sources</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <v-list-tile @click="drawer = !drawer" to="/entry/witnesses">
                        <v-list-tile-content>
                            <v-list-tile-title>Witnesses</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>

                    <v-divider dark></v-divider>

                    <v-subheader class="mt-3 grey--text text--darken-1">ADMIN</v-subheader>
                    <v-list-tile @click="drawer = !drawer" to="/Admin/Users">
                        <v-list-tile-content>
                            <v-list-tile-title>Users</v-list-tile-title>
                        </v-list-tile-content>
                    </v-list-tile>
                    <br />
                </v-list>
            </v-navigation-drawer>
            <v-toolbar color="indigo" dark fixed app>
                <v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
                <v-toolbar-title>Mpid2</v-toolbar-title>
            </v-toolbar>
            <v-content>
                <router-view></router-view>
            </v-content>
            <v-footer fixed app height="auto" style="min-height: 0">
                <!--<v-progress-linear :active="isPageLoading" class="ma-0" :indeterminate="true"></v-progress-linear>-->
            </v-footer>
        </v-app>
    </div>
</template>

Answer №1

Switching from @click.stop to @click.native fixed the issue with the drawer.

Answer №2

If you have implemented Vuex in your project and wish to avoid double-clicking, there is a simple solution:

step 1) Utilize the v-click-outside directive from Vuetify by importing it, then restart your system.

step 2) Apart from your existing methods defined in HTML, create an additional method specifically for this directive. Here's an example:

<v-list-tile 
@click="drawer = !drawer" 
***v-click-outside="onClickOutside" 
to="/entry/records">
 <v-list-tile-content>
<v-list-tile-title>Records</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>

step 3) Define the following method as shown below:

onClickOutside() {
  this.$store.commit('appRoot/isPageLoadingUpdate', value)
},

step 4) It is crucial to ensure that if drawer: false, you prevent the method from execution. Use the code snippet below as a guide:

onClickOutside() {
if (drawerAction === true) { 
this.$store.commit('appRoot/isPageLoadingUpdate', value)}
},

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling with the jquery .hover method

Encountering an issue with the jquery .hover function. It seems to only work if I place it inside a generic $(function(){. I have observed it being done without this generic function, so if anyone can point out what I might be doing incorrectly, I would be ...

Tips on positioning a div based on the screen dimensions

In my table, there is an icon that reveals a chart as a popup when hovered over. This div is where the chart is displayed: <div id="chart-outer" style="@style" class="popup-chart close"> <h2 id="charttitle&q ...

Issue with FusionCharts rendering correctly arises when the <base> tag is present in the HTML head section

Combining AngularJS and FusionCharts in my web application has led to a unique issue. The upcoming release of AngularJS v1.3.0 will require the presence of a <base> tag in the HTML head to resolve all relative links, regardless of the app's loca ...

"Utilize Meteor to transmit emails to internal email addresses within the intran

I have successfully developed a Meteor App to manage requests. However, I am facing an issue where I need emails with default text to be sent whenever a request is created or updated. The challenge lies in the fact that I am operating within an intranet e ...

Showing JSON information in an Angular application

Upon page load, I am encountering an issue with retrieving and storing JSON data objects in Angular scope for use on my page and in my controller. When attempting to access the value, I receive the error message: angular.js:11655 ReferenceError: data is ...

Invoking a REST API synchronously using JavaScript

I am just starting out with JavaScript and the npm ecosystem. I am attempting to upload data to my REST service using a POST call. The data is being fetched from a CSV file, which is going well so far. For each line of data that is fetched, I convert it as ...

How can I organize data from A to Z in alphabetical order in React Native when the user chooses the A to Z option from the dropdown menu?

I am working on a screen that can display up to 1000 data retrieved from the API. Here is the image: https://i.sstatic.net/ErbDD.png Now, I have implemented a drop-down box where users can select alphabetically from A to Z. After selecting an alphabetic ...

Using jQuery's .grep() method on an array will only return the final digit

Could someone help me understand the behavior of jQuery's .grep() method? I'm creating a jQuery object array based on the names of these elements: <div class="small1 other">S1</div> <div class="small2">S2</div> <div c ...

What is the process of synchronizing state in react.js?

I am struggling to update the state and component in my code. When I press a button and change the value of one of the props in the popup component, the prop value does not get updated. I suspect this issue is due to using setState. I researched a possible ...

Receiving a 401 error while attempting to make an axios get request with authentication headers

I have been utilizing axios in my React project to fetch data from MongoDB. However, I am facing a challenge with the axios get requests returning a 401 error when I include my auth middleware as a parameter. This middleware mandates that the user must pos ...

Converting a text file to JSON format using Adobe Acrobat: A tutorial on proper referencing

I am facing an issue with converting a string from a file attached to my PDF (JSONTEST.txt) into JSON format so that I can reference it using obj[key]. Despite trying to use eval(), I encounter the following error every time: SyntaxError: missing ; before ...

Is there a way to maintain the checked status of the checkboxes after a page refresh?

Is there a way to keep the checkboxes checked even after the page is refreshed in this code snippet? Any code sample or explanation on how to achieve this would be highly appreciated. The complete project code can be found here: https://github.com/Orelso/P ...

Vue messaging application fails to display data upon mounting

Recently, I've been experimenting with different Vue chat libraries and encountered this interesting piece of code: <template> <p>{{ this.users[0] }}</p> </template> <script> export default { data() { return ...

Can anyone provide guidance on adjusting the color of the axes on a c3 chart within a Vue environment

I am struggling to change the axis color of my c3 chart in a Vue app where I have successfully built the chart using c3.js. The issue is not just limited to the axis color; I find it difficult to customize any style on the c3 charts, which is quite frustr ...

Exploring the world of Vue.js with the latest vue-cli 3.0 and integrating Google Web

I'm completely confused about incorporating Google Fonts into my project. Despite installing the google-fonts-webpack-plugin and attempting to configure it correctly, the html is not being injected. Perhaps I am approaching this problem from the wron ...

Latest News: The store is now received in the mutation, instead of the state

An update has been made to this post, please refer to the first answer After thorough research, I couldn't find a solution to my issue despite checking several threads. This is my first time using the Quasar framework and it seems like I might have o ...

What is the method for checking the pathname condition?

Hello, I am attempting to create an if statement for the pathname, but I am having trouble getting it to work properly. if (pathname == "/") { category = 'home'; pagetype = 'homepage'; } If the pathname matches "/", the script ...

Error in IONIC 3: The code is unable to read the 'nativeElement' property due to an undefined value, resulting in a TypeError

I am currently learning about IONIC 3 and working on an app that utilizes the Google Maps API. However, when I try to launch my app, I encounter the following error message: inicio.html Error: Uncaught (in promise): TypeError: Cannot read property ' ...

In a Next.js project, Typescript seems to be overlooking errors related to proptype definitions and function types

Greetings everyone! I am currently working on a project using TypeScript and have implemented various rules and elements. However, I am facing issues with type errors for functions and props. Essentially, when using any function, it is necessary to specify ...

Problem with AngularJS factory causing issues with promises

I have a factory in AngularJS set up like this: 'use strict'; angular.module('frontRplApp') .factory('paymentService', function ($rootScope, $http, config, tools) { var urlBase = config.baseUrl; var payme ...