Repeatedly opening the dialog in a Vue.js app leads to a Maximum Call Stack error

I am currently facing an issue with my Vue.js application. I have successfully implemented a data table where the content is fetched from an API call. After the app is mounted, I make the API call and populate an Array with the response data, which is then displayed in the table. Now, I want to introduce a feature that allows users to add notes to each row by opening a dialog box and passing the ID of the specific row to it for saving the note.

I managed to implement the dialog box without the ID functionality, so every row behaves the same way. However, I encountered a problem that I need to resolve before moving forward.

When I click on the button to open the dialog, the background appears very blurry, as shown in the image below.

https://i.sstatic.net/4sPbT.png

If I try to save and reopen the dialog multiple times, I receive an error message and the page becomes unresponsive. I have to open a new tab and revisit the link.

https://i.sstatic.net/gUv8t.png

The following code snippet shows the history component where every button resides:

<v-data-table
          :headers="headers"
          :items="history"
          :search="search"
          class="elevation-1"
        >
          <template v-slot:item.recording>
            <v-dialog v-model="dialog" max-width="400px">
              <template v-slot:activator="{ on, attrs }">
                <v-btn
                  icon
                  small
                  @click="dialog = true"
                  v-bind="attrs"
                  v-on="on"
                >
                  <v-icon small> mdi-content-save</v-icon>
                </v-btn>
              </template>
              <NoteToHistoryDialog :noteId="noteId" v-on:close-card="dialog = false" />
            </v-dialog>
            <v-btn icon small @click="downloadAttachment">
              <v-icon small> mdi-download</v-icon>
            </v-btn>
          </template>
        </v-data-table>

Below is the code for the NoteToHistoryDialog component:

<template>
  <v-main>
    <v-card>
      <v-card-title class="primary white--text">{{  $t("Add Note") }}{{ noteId }}</v-card-title>
          <v-form>
            <v-text-field
                color="primary"
                label="Text"
                class="pr-4 pl-4"
                v-model="note"
            >
            </v-text-field>
          </v-form>
      <v-card-actions class="justify-end">
        <v-btn depressed plain color="primary white--text" @click="$emit('close-card')">
          {{ $t("Close") }}
          <v-icon>mdi-close</v-icon>
        </v-btn>
        <v-btn depressed plain color="primary white--text" @click="addNote">
          {{  $t("Save") }}
          <v-icon>mdi-content-save</v-icon>
        </v-btn>
      </v-card-actions>
    </v-card>
  </v-main>
</template>

At this point, everything seems to be functioning properly.

Additionally, here is an image showcasing the entire component. The dialog is triggered when clicking on the small disk icon.

https://i.sstatic.net/X2XQZ.png

Thank you for any suggestions or ideas to resolve the issue.

Answer №1

After successfully resolving the issue, I decided to create a new component. I copied and pasted the entire CRUD table from Vuetify documentation and meticulously edited every line to tailor it to my specific requirements. Now, I am delighted that I can effortlessly click on the "Add Note" button multiple times without encountering any issues.

Below is the functional code snippet:

<v-data-table
  :headers="headers"
  :items="history"
  sort-by="date"
  class="elevation-1"
>
  <template v-slot:top>
    <v-dialog v-model="dialog" max-width="500px">
      <v-card>
        <v-card-title class="primary white--text">
          <span class="text-h5">{{ $t("Add Note") }}</span>
        </v-card-title>

        <v-card-text>
          <v-container>
            <v-row>
              <v-col cols="12" sm="12" md="12">
                <v-form>
                  <v-textarea
                    color="primary"
                    label="Text poznámky"
                    v-model="editedItem.note"
                    auto-grow
                    clearable
                    >
                  </v-textarea>
                </v-form>
              </v-col>
            </v-row>
          </v-container>
        </v-card-text>

        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="primary" text @click="close">
            Zrušiť
          </v-btn>
          <v-btn color="secondary" text @click="save">
            Uložiť
          </v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
    <v-dialog v-model="dialogDelete" max-width="500px">
      <v-card>
        <v-card-title class="text-h5"
          >Chcete stiahnuť nahrávku?</v-card-title
        >
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="primary" text @click="closeDelete"
            >Zrušiť</v-btn
          >
          <v-btn color="secondary" text @click="deleteItemConfirm"
            >OK</v-btn
          >
          <v-spacer></v-spacer>
        </v-card-actions>
      </v-card>
    </v-dialog>
  </template>
  <template v-slot:item.recording="{ item }">
    <v-icon small class="mr-2" @click="addNote(item)">
      mdi-content-save
    </v-icon>
    <v-icon small @click="downloadRecording(item)">
      mdi-download
    </v-icon>
  </template>
</v-data-table>

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

Creating a Class in REACT

Hello fellow coding enthusiasts, I am facing a minor issue. I am relatively new to REACT and Typescript, which is why I need some assistance with the following code implementation. I require the code to be transformed into a class for reusability purposes ...

Apply a unique color to the highest value within each column using AngularJS ng-repeat

I just started learning Angularjs, and I'm not sure how to achieve this. I want to highlight the member with the highest Score, Missed, and Field Goal percentage by adding color. Is there a way to do this? https://i.sstatic.net/9KF5D.png Is it poss ...

Error encountered in Angular 7.2.0: Attempting to assign a value of type 'string' to a variable of type 'RunGuardsAndResolvers' is not allowed

Encountering an issue with Angular compiler-cli v.7.2.0: Error message: Types of property 'runGuardsAndResolvers' are incompatible. Type 'string' is not assignable to type 'RunGuardsAndResolvers' This error occurs when try ...

Node js process.kill(pid) is ineffective in terminating a Linux process

Trying to terminate background processes using nodejs process.kill(pid, 'SIGTERM') results in the processes not being killed. After running the node script provided below, I checked the processes using ps -efww | grep 19783 | grep -v grep in the ...

Nodejs: A function is expected in the instanceof check, but an undefined value was provided

Encountering a peculiar error while using node-webkit, here's a detailed example to replicate it: index.js: var jQuery = require('jquery'); var Backbone = require('backbone'); (function($){ var ListView = Backbone.View.extend( ...

After mapping in JavaScript, delete the property name

Is there a way to exclude the property name from the returned value? I want to eliminate the property name "projects: [ ]" from the output. router.get("/", (req, res, next) => { Project.find() .exec() .then(docs => { res.status(200) ...

Using jQuery to search for corresponding JSON keys in the PokéAPI

Currently, in my development of an app, I am searching for and implementing an English translation of a language JSON endpoint using the PokéAPI. The challenge lies in identifying the correct location of the English language key within the array response, ...

Using recursion in JavaScript to determine if a given number is prime

I am feeling a bit puzzled about how to tackle this issue. My goal is to have all prime numbers return as true, and if not, then false. I noticed that my current logic includes 2, which returns 0 and automatically results in false because 2 has a remainder ...

What is the most effective way to populate an element using jQuery?

When you click a button with jQuery, I am generating a modal (Bootstrap modal) as a string. This modal has two option classes: Call Today and Call Tomorrow, which seems fine so far. Upon clicking the button, the modal is created, prompting me to add two a ...

Route.get() is looking for a callback function, but instead received an [object Promise]

Currently, I am in the process of developing a REST API using express and following the architecture outlined in this particular article. Essentially, the setup involves a router that calls a controller. Let me provide you with an example of how a call is ...

Is it possible to reuse a variable within a single HTML tag when using Angular 2?

I encountered a strange issue with Angular 2 that may be a bug. I noticed that I couldn't print the same variable in a template twice within the same HTML tag. When I tried to use the following code, it resulted in error messages. <div class=" ...

Storing images in MongoDB using React.js

I'm currently facing an issue with uploading an image file from the client side to MongoDB. To achieve this, I am utilizing an Express server along with 'multer' and 'sharp' for image uploading. On the client side, I have a CRA a ...

Unable to call an object that may be 'undefined': Utilizing a function with a return object that includes asynchronous functions as properties

I have a function exported in my adapter.ts file: import type { Adapter } from "@lib/core/adapters"; export default function MyAdapter (): Adapter { return { async createUser (user: User) { ... }, async findUserByEmail (email ...

Is there a barrier I've reached with the amount of hashtags I'm using?

My goal is to limit the use of javascript and rely more on CSS to achieve desired effects on my website. One feature I have developed is a modal that opens using hashtags and targets, similar to this example: http://codepen.io/maccadb7/pen/nbHEg. While th ...

Utilizing *ngfor in Angular 7 to Group and Display Data

I currently have incoming data structured like this in my Angular application Visit this link to see the data format https://i.stack.imgur.com/jgEIw.png What is the best way to group and sort the data by State and County, and present it in a table as sh ...

jQuery auto-suggest feature failing to display search results

Just to clarify, I have very little experience with JS, so my understanding is limited. Fair warning :-) I'm currently working on an autocomplete menu that retrieves data from a webservice. This webservice will return various types of elements (such ...

The THREE.Raycaster is detecting intersections with the mesh's initial position following the position.set() method

When using Three.js, I encountered an issue where the THREE.Raycaster does not recognize an object's new position set using position.set(). If the object is left at the default position of 0,0,0, the mesh is properly intersected. function initialize( ...

What is causing the data to be altered outside of the directive scope?

I am having trouble understanding why the data is changing outside the directive in the external div. I expected it to behave the same as in the controller because the external Div is not wrapped in a directive or controller. Therefore, it should remain un ...

What is the best way to access document identifiers in a Firestore Database?

I am completely new to working with Angular, Firestore, and Firebase. Currently, I have a component set up that successfully retrieves all my hero documents. I was able to display their names in a list. However, my next goal is to retrieve the unique ID f ...

How to retrieve a JSON value without a key using jQuery

I am struggling to fetch JSON using jQuery. If anyone can help me figure out the mistake in my code that would be greatly appreciated. The data.json file contains { "value1", "value2", "value3", "value4" } Here is my jQuery code $.getJSON( "data.js ...