Issue with activating a button using v-slot activator

In my Vuejs project, I am utilizing v-slot:activator with v-btn. Everything is functioning properly, except that the button remains in a hovered state as if it has been pressed.

       <v-dialog v-model="dialog" max-width="600px">
        <template v-slot:activator="{ on, attrs }">
          <v-btn color="#F65C38" dark class="mt-1 mr-2" width="209px" v-on="on" v-bind="attrs"> Example Btn </v-btn>
        </template>
        <v-card>
          <v-card-title>
            <span class="text-h5">{{ formTitle }}</span>
          </v-card-title>

          <v-card-text>
            <v-form ref="form" v-model="valid">
              <v-container>
                <v-row>
                 

                  
               
           
                </v-row>
              </v-container>
            </v-form>
          </v-card-text>

          <v-card-actions class="d-flex justify-center">
            <v-btn color="#f66037" plain @click="close" elevation="4" dark width="209" class="mb-6"> No </v-btn>
            <v-btn color="#F65C38" @click="save" dark width="209" class="mb-6"> save </v-btn>
          </v-card-actions>
        </v-card>
      </v-dialog>

data:

dialog: false

watch:

  dialog(val) {
      val || this.close();
    },

method:

    close() {
  this.dialog = false;
  this.$nextTick(() => {
    this.editedItem = Object.assign({}, this.defaultItem);
    this.editedIndex = -1;
  });

before click https://i.sstatic.net/osHCY.png

after clickhttps://i.sstatic.net/5BzN0.png

Answer №1

If you want to manually remove focus, you can use the native JavaScript method:

document.activeElement.blur()

To implement this in your code example, you can insert this line within $nextTick:

...
close() {
  this.dialog = false;
  this.$nextTick(() => {
    this.editedItem = Object.assign({}, this.defaultItem);
    this.editedIndex = -1;
    document.activeElement.blur()
  });
},

You can test this out on CodePen.

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

Compress and condense AngularJS Source Code without using NodeJS

I'm looking to beautify and compress my AngularJS source code. I came across Grunt as a potential solution, but it requires NodeJS which our website doesn't support. I haven't been able to find any suitable alternatives. Any suggestions? ...

What is the most effective way for me to utilize callback functions and setTimeout in my code?

I am facing an issue where I need to transfer data from fileExistance to result and then export the result to budget.js in the router folder. However, I am encountering the following error: internal/validators.js:189 throw new ERR_INVALID_CALLBACK(callbac ...

What is the best way to display two arrays next to each other in an Angular template?

bolded text I am struggling to display two arrays side by side in an angular template. I attempted to use ngFor inside a div and span but the result was not as expected. A=[1,2,3,4] B=[A,B,C,D] Current Outcome using ngFor with div and span : Using Div : ...

Trying to iterate through and make changes to a Firebase array results in an undefined

Update: Upon further investigation, it appears that value[i].extrainfoimage is only undefined when accessing imageRef.child("-JlSvEAw...... Despite reviewing the documentation multiple times, I still haven't been able to resolve this issue. Essentia ...

Why aren't my cookies being successfully created on the frontend of my application when utilizing express-session and Node.js?

Having trouble setting cookies while using express-session in my MERN stack project. When accessing endpoints from frontend localhost:3000 to backend localhost:8080, the cookies do not set properly. However, everything works fine when both frontend and b ...

Saving the selected value from a dynamic dropdown menu in a JavaScript application to a MySQL database

This code successfully saves the values of departments but is encountering an issue with saving the degree value into MySQL. I am currently using PHP for this functionality. Here is the HTML code: <select class ="form-control" name="depa ...

Have you ever encountered the frustration of being unable to navigate to the next page even after successfully logging in due to issues

I'm currently utilizing Vue and Firebase to build my application. One of the features I want to implement is the redirect method using vue-router. Within my vue-router code, I've included meta: { requiresAuth: true } in multiple pages as middlew ...

What could be causing the PHP JSON response to fail in sending the data array back to the AJAX jQuery request?

After making an ajax request to the PHP server, I am sending data from a form request and expecting to receive the same data back from the server for testing purposes. This will help me analyze the requests and responses between the client and the server. ...

Exploring the iteration of objects utilizing underscore.js

Currently, I am diving into the world of backbone.js and encountering a slight issue while iterating over some models in a view. The first code snippet seems to be functioning correctly, but the second one, which is underscore.js-based, does not work as ex ...

Is it optimal to count negative indexes in JavaScript arrays towards the total array length?

When working in JavaScript, I typically define an array like this: var arr = [1,2,3]; It's also possible to do something like: arr[-1] = 4; However, if I were to then set arr to undefined using: arr = undefined; I lose reference to the value at ...

Mastering the art of nested await functions in JavaScript

In my current Nodejs application using mongoose, I am implementing cache with MongoDB in-memory and MongoDB database. This setup is running on Nodejs 8.9 with async/await support enabled. let get_func = async(userId) => { let is_cached = await c ...

Struggles with establishing a connection to the Gmail API

I am facing some challenges connecting to the Gmail API. Despite completing the setup process and obtaining a valid token on OAuth 2.0 Playground, I encounter errors when trying to send mail from a form on my Node.js / Express / Nodemailer server. The term ...

Interactive scrolling bar chart created with D3.js

Let's take a look at a simple bar chart: var margin = {top: 20, right: 20, bottom: 30, left: 50}; var xLPU=d3.scale.ordinal(); var yLPU=d3.scale.linear(); var xLPUAxis = d3.svg.axis() .scale(xLPU) .orient("bottom"); var yLPUAxis = d3.svg.axi ...

Leveraging the execute script command in Selenium IDE to determine the time duration between two dates displayed on the webpage

For work automation, I've been utilizing SIDE to streamline certain tasks. One challenge I'm facing involves extracting dates from a page using the store command and then attempting to calculate a duration using the execute script command, which ...

When you click on the element, data is initially loaded through an ajax request. Subsequent clicks will not trigger any additional ajax requests

$.ajax({ type: "POST", url: "/php/auth/login.php", data: $("#login-form").serialize(), success: function(response) { // do something with the response }, complete: function() { ...

What steps can I take to prevent already selected options from being chosen in a Vue.js HTML form?

Among my json data, I have a list of all inventories: { "status": true, "data": [ { "inv_id": 1, "name": "Arts" }, { "inv_id": 2, "name": "web" }, { "inv_id": 3, "name": "mobileapp" }, { "inv_id": 4, "name": "ws" }, { "inv_id": 5, ...

The advantages and disadvantages of utilizing various methods to visually enhance HTML elements with JavaScript

After opening one of my web projects in IntelliJ, I noticed some JavaScript hints/errors that Netbeans did not detect. The error message was: > Assigned expression type string is not assignable to type CSSStyleDeclaration This error was related to thi ...

Express routes are malfunctioning

I have a situation with two different routes: /emails and /eamils/:id: function createRouter() { let router = express.Router(); router.route('/emails/:id').get((req, res) => { console.log('Route for get /emails/id'); }); ...

Adding a three-dimensional perspective to an HTML5 canvas without utilizing CSS3 or WebGL

Here is a canvas I am working with: http://jsbin.com/soserubafe Here is the JavaScript code associated with it: var canvas=document.getElementById("canvas"); var ctx=canvas.getContext("2d"); var w = canvas.width; var h = canvas.height; var cw=canvas. ...

What is the best way to implement a timer or interval system in React and Next.js that continues running even when the tab is not in focus or the browser is in

I am attempting to create a stopwatch feature using next js. However, I have encountered an unusual issue where the stopwatch does not function correctly when the tab is not focused or when the system goes to sleep or becomes inactive. It appears that the ...