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

Tips on creating a subsequent post for a file that has been uploaded to a Node Express server and then forwarded to a different API

We are currently working with an Express server in Node, where we upload a file on one route and then need to send this file to another endpoint for processing. However, the file is not stored locally on the server; it exists as an uploaded object. I&apos ...

Can you rely on a specific order when gathering reactions in a discord.js bot?

Imagine a scenario where a bot is collecting reactions to represent event registrations. To prevent any potential race conditions, I have secured the underlying data structure with a mutex. However, the issue of priority still remains unresolved as user # ...

What is the best way to open a link contained within a div by clicking on it

I am currently in the process of developing a website that is able to parse a Spanish dictionary. When looking up the word HOLA, the site provides the definition. However, for other words like CASA, users receive suggestions with links such as My goal is ...

Tips for testing views in ember.js using unit tests

We are currently delving into the world of Ember.js. Our development process is completely test-driven, and we aim to apply the same methodology to Ember.js. Having prior experience in test-driven development with Backbone.js apps using Jasmine or Mocha/Ch ...

Is it possible to create a channel list using the YouTube API if I am not the owner of the channel? I am not getting any errors, but nothing is showing up

I am currently working on creating a channel list and playlist of videos from a Music channel that I do not own. Here is the link to the channel: https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/featured. My goal is to extract data from this channe ...

The background image on my link bar is inexplicably not appearing

I've been trying to solve this issue for hours and I'm at a loss. Initially, the background image was displaying correctly, but now it's not working. HTML: <head> <link type="text/css" rel="stylesheet" href="css/normalize.css" ...

Issue with styling Icon Menu in material-ui

I'm having trouble styling the Icon Menu, even when I try using listStyle or menuStyle. I simply need to adjust the position like this: It currently looks like this: Update: Here's an example: import React from 'react'; import IconM ...

Preserve multiple selected values post form submission using PHP, HTML, and JavaScript

How can I retain the selected values in a form after it is submitted? My current code functions correctly when only one value is selected, but does not maintain all selected values when multiple are chosen simultaneously. Any assistance would be apprecia ...

Extract data from Markit On Demand API using JavaScript and AJAX

I'm struggling to properly parse the response from the API. While I can retrieve the entire response, I am a bit lost on how to effectively parse it. Below is my code snippet: <!DOCTYPE> <html> <head> <style> img ...

Is there a way to effortlessly refresh a viewpage with fresh data directly from Firebase?

I am trying to update my HTML page with new data from Firebase in real time without having to refresh the entire page. However, I am facing issues where the view is not updating automatically. How can I achieve this? In my JavaScript file, I query Firebas ...

Converting an onclick event to onsubmit: Tips for doing it right

Recently, I had to add validation to a file upload form for our Google Drive. After some research, I discovered that using onsubmit instead of onclick was the way to go. However, when I made the switch from onclick to onsubmit, the validation worked but t ...

ES5 approach to Angular2 HTTP Providers (not TypeScript)

I'm currently developing an application and experimenting with Angular2 using ES5 JavaScript for fun. My main inquiry right now is how to access the Http service. Most of the available documentation is in TypeScript, which is not very helpful, or it p ...

Is it possible to find a match by searching through multiple arrays for a corresponding variable name?

Hi there, I'm currently working on a function that triggers an alert if the name of an array of images matches the data attribute of the selected element. This is just a test phase before proceeding with my main project, but I've hit a roadblock. ...

Horizontal expanding and collapsing navigation menu

Is there a way to modify the expand menu bar so it expands from left to right or right to left, instead of top down? Any assistance would be greatly appreciated. Existing Expand Menu Bar <HTML> <HEAD> <META http-equiv="Content-Type" c ...

Show small information box when hovering over custom toggle button

I have developed a unique custom toggle switch feature When I hover my mouse over the switch, it should display a tooltip message as YES if the switch is in the ON position and NO if it's in the OFF position. Is there a way to implement this functio ...

In Javascript, when declaring a variable, check if a field is filled and assign its value if so; otherwise, set a default value

In the code snippet below, there are some rows with a nested field value present and some without. I am attempting to assign a value if the field is present, otherwise I want to set it as 'false'. Despite using the double pipe operator to handle ...

troubleshoot using Visual Studio Code

Here's the scenario: I need to debug a project using VS Code. The project is usually started by a batch file and then runs some JavaScript code. Now, I want to debug the JavaScript code, but I'm not sure how to do that. If anyone has any instruct ...

Having trouble getting Bootstrap 4 SCSS overrides to take effect?

Let's dive into a quote from the Bootstrap documentation: Each Sass variable in Bootstrap 4 comes with the !default flag, allowing you to modify the default value in your own Sass even after that original variable has been set. Here is the content ...

Utilizing jspm for installing npm packages along with their dependencies

When using jspm, I can easily install npm packages by running: jspm install npm:<pkg-name>. This allows me to use the package in development, like so: import myPackage from 'myPackage';. If the package.json file of the npm package includes ...

What is the best way to prevent input fields from wrapping onto a new line in a Bootstrap 4 inline form layout?

I am facing an issue with my inline form where the input fields are wider than the screen, causing some of them to fall onto a new line. <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="u ...