Is there a way to collapse child elements in a hover sidebar using Vuetify?

My project includes a sidebar that opens when I hover over it with the mouse. Everything works fine, but within the sidebar, there is a collapse dropdown menu. When I open this menu and then move the mouse away from the sidebar and back again, the collapse remains open. You can see this more clearly in the screenshots. What I want is for there to be no space between the icons when the sidebar is closed.

Template sidebar

<v-navigation-drawer width="320" :disable-resize-watcher="true">
      <v-list v-if="userRole == 'Distributor' || isSuper">
        <v-list-tile
          :append="true"
          v-for="(item, index) in distMenu"
          :key="index"
          :class="{
            'active-sidebar-item': item.href.includes(activeLinkRef),
          }"
          style="margin-bottom: 5px;"
        >
          <v-list-tile-action>
            <v-icon>{{ item.icon }}</v-icon>
          </v-list-tile-action>
          <v-list-tile-content>
            <v-list-tile-title>
              <router-link :to="item.href">{{
                item.title
              }}</router-link></v-list-tile-title
            >
          </v-list-tile-content>
        </v-list-tile>
      </v-list>
      <v-list v-if="userRole == 'Sysadmin' && !isSuper">
        <v-list-tile
          :append="true"
          v-for="(item, index) in sysMenu"
          :key="index"
          :class="{
            'active-sidebar-item': item.href.includes(activeLinkRef),
          }"
          style="margin-bottom: 5px;"
        >
          <v-list-tile-action>
            <v-icon>{{ item.icon }}</v-icon>
          </v-list-tile-action>
          <v-list-tile-content>
            <v-list-tile-title>
              <router-link :to="item.href">{{
                item.title
              }}</router-link></v-list-tile-title
            >
          </v-list-tile-content>
        </v-list-tile>
      </v-list>
      <v-list v-if="userRole != 'Distributor' || isSuper">
        <v-list-tile
          :append="true"
          v-for="(item, index) in menu"
          :key="index"
          :class="{
            'active-sidebar-item': item.href.includes(activeLinkRef),
          }"
          style="margin-bottom: 5px;"
        >
          <v-list-tile-action>
            <v-icon>{{ item.icon }}</v-icon>
          </v-list-tile-action>
          <v-list-tile-title>
            <router-link :to="item.href">{{ item.title }}</router-link>
          </v-list-tile-title>
        </v-list-tile>
        <Facilities
          :facilities="facilities"
          v-if="
            (userRole.toLowerCase() != 'distributor' && hasCompany) ||
              isSuper
          "
          :activeLinkRef="activeLinkRef"
        ></Facilities>
      </v-list>
    </v-navigation-drawer>

Facilities.vue

  <v-list-group
      prepend-icon="business"
      :value="false"
      v-for="(facility, index) in facilities"
      :key="index"
      :class="{
        'active-sidebar-item':
          activeLinkRef[0] == 'facility' && activeLinkRef[1] == facility.id,
      }"
      style="margin-bottom: 5px"
    >
      <template v-slot:activator>
        <v-list-tile :append="true">
          <router-link :to="'/facility/' + facility.id">{{
            facility.name
          }}</router-link>
        </v-list-tile>
      </template>
      <systems
        :systems="facility.systems.length > 0 ? facility.systems : []"
        :facility="facility.id"
        :activeLinkRef="activeLinkRef"
      ></systems>
    </v-list-group>
    <v-list-tile
      class="input-list-tile"
      v-if="isSuper || userRole.toLowerCase() == 'sysadmin'"
    >
      <v-list-tile-title
        style="padding-left: 54px; height: 40px"
        class="input-option"
      >
        <!-- <input
          style="border: 1px solid #dedede"
          type="text"
          name="add-facility"
          id="add-facility"
          :placeholder="$t('sidebar.addFacility')"
          @keyup.enter="addFacility"
        /> -->
        <b-form-input
          size="sm"
          style="border: 1px solid #dedede"
          class="w-100"
          name="add-facility"
          id="add-facility"
          :placeholder="$t('sidebar.addFacility')"
          @keyup.enter="addFacility"
        ></b-form-input>
      </v-list-tile-title>
      <v-list-tile-action style="justify-content: right;">
        <v-icon @click="addFacility">add</v-icon>
      </v-list-tile-action>
    </v-list-tile>

When the mouse is not over the sidebar

https://i.stack.imgur.com/RCslE.png

After opening the sidebar, everything seems to work correctly.

https://i.stack.imgur.com/1SKyo.png

However, once I move the mouse away from the sidebar, it closes and shows this image

https://i.stack.imgur.com/ro8us.png

Answer №1

Start by hiding your collapse menus.

Define a new class like this:

.show-menu {
   display: block;
}

To handle the click event, you can use this jQuery code:

$("dropdown-class").click(function(){
  $("your-tag-here").toggleClass("show-menu");
});

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

How come I keep running into the "is not a function" issue when trying to use the generateRequest function with Polymer's iron-ajax

Oops, it seems like there was an error: Uncaught TypeError: this.$.ajax.generateRequest is not a function. The issue seems to be in assets-ajax.html at line 23. <dom-module id="assets-pull"> <style> </style> <template> <but ...

Scrollbars in Jquery are not visible anymore when adjusting the size of a div element, causing them to expand

I'm facing an issue with a layout containing a div that expands to the screen size upon clicking a button. Initially, the div has enough content to necessitate scrolling. However, after collapsing back to its original size, the scroll bar disappears a ...

Using VML for background images in Outlook using HAML: A step-by-step guide

I am currently working on formatting an email digest using HAML and tables. My goal is to set a background-image to a table-cell in the email, but I've come to realize that Outlook requires VML in order to display a background-image correctly. After ...

Configure Laravel application to use a specific language locale in the app.php file

Whenever the user selects a different language, I attempt to set it as the local language. However, whenever the page is refreshed, it reverts back to my default language... 'locale' => 'en', 'locales' => ['fr&apos ...

When integrating React with Tawk, the user's name and email are automatically encoded before being sent

My code within the componentDidMount() function initializes a widget popup when the page loads. It then sets the name and email using parameters received from the previous page. const fullName = this.state.data[0]; console.log(fullName); const e ...

The preflight request for Firebase Storage CORS did not pass the access control check due to not having an HTTP status of ok

When attempting to upload an image to Firebase Storage, I encountered an error in the Chrome console: Access to XMLHttpRequest at 'https://firebasestorage.googleapis.com/v0/b/%22website-admin-c9ce6.appspot.com%22VITE_APP_VERSION%3D0.0.0/o/MYx2YMuRBw ...

Using node.js version 10.0.0 to tinker with gulp

I was working on a node.js api project that functioned perfectly with node.js v8.1.4 & npm v5.0.3. However, upon transitioning to node.js v10.0.0 & npm v5.6.0, I encountered the following error: [email protected] ecosystem E:\opensource& ...

The comparison between using multiple Vue.js instances and components, and implementing Ajax tabs

I am looking to incorporate ajax tabs using vue js. Each tab will need an ajax request to fetch both the template and data from an api. Here is an example of the tabs: <div id="tabs"> <ul class="nav nav-tabs"> <li class="active">& ...

Tips on creating a "CSS3 blink animation" using the visibility attribute

I'm attempting to create an old-school blink effect on some DIVs. They should start off as invisible and then quickly become visible for a moment, repeating this sequence in an infinite loop. According to CSS specifications, the "visible" property is ...

Automatically load content using AJAX when scrolling within a HTML5 segment

Recently, I've been developing a website that dynamically loads new content from a MySQL database as the user scrolls. However, I've encountered an issue where the new content is loaded even with minimal scrolling, rather than only when reaching ...

What is the best way to handle multiple responses in Ajax within a single function?

Here is a simple code snippet: $.ajax({ url:'action.php', method: 'POST', data:{getcart:1}, success:function(response){ $('#getcart').html(response);//want to ...

Ensure that the response key in Node.js Sequelize remains null when using Vue2

my response json if null dm_personal: null if not null if null dm_personal: { id: 1 } how can I ensure that the key of the response remains null? or how can I handle this in Vue2 when fetching or loading a single data and setting data() { return {} } ...

The SVG animation is reversing and decreasing in size from the bottom

Feeling lost, I spent a day searching without success. I have a project in full Vuejs and I thought using Svg would be easy and fun, but I can't figure out why the image resizes when playing an animation. The bottom of the svg seems to resize and get ...

Experience the power of Kendo UI Date Picker combined with AngularJS. When the datepicker is initialized, it starts

Check out my code snippet below: When the datepicker loads initially, it appears empty. However, if you remove ng-model from the directive template, the datepicker displays its initial value correctly. Yet, changing the selected date does not mark the fo ...

Access a PHP file using XMLHttpRequest to run additional JavaScript code

My main page, referred to as Main.php, contains a button that triggers the display of results from Results.php within a div (divResults) on Main.php. The HTML content "These Are The Results" returned by Results.php is successfully displayed in the divResu ...

Uh oh: encountered an unexpected token 'export' in node_modulesexpoAppEntry.js

I'm encountering a challenge with my Expo project. While attempting to launch my app using yarn start, I'm running into this error: Android Bundling failed 449ms error: node_modules\expo\AppEntry.js: Unexpected token 'export&apo ...

A guide to extracting iFrame information (specifically the referring URL) using JavaScript

Is there a way to retrieve the information from an iFrame (right-click on an iFrame in the browser -> This Frame -> View frame info)? I'm particularly interested in obtaining the referring URL. So far, I managed to retrieve the address using contentD ...

Execute a function on a canvas timer using the setTimeout method

I'm having an issue with my setTimeout function in this code. I want it to call a timer function for a delay, but it's not working consistently every second. Why is that happening? <head> <script> function timer(sec) { var c = do ...

How can markers be filtered on a Google Map API without the need to refresh the map?

I have created an Angular JS module that utilizes the Google Map API. The map is defined as a global variable, along with a global array for markers, and functions for managing these markers such as removing them, resetting the map, and adding new markers. ...

"Guidelines for implementing a post-login redirection to the homepage in React with the latest version of react-router (v

I am facing an issue where I am unable to redirect to the Home Page when I click the "Login" button during my React studies. Despite trying all possible methods for redirects, none of them seem to work. The function that is executed when I click the "logi ...