17

I am Using Vuetify Dialog And this is My code

<v-dialog  max-width="390" persistent  v-model="dialog">
  <template v-slot:activator="{ on }">
    <v-btn icon v-if="el.items_count == 0" v-on="on" >
        <v-icon>
          mdi-plus
        </v-icon>
      </v-btn>
  </template>
  <v-card flat>
    <v-card-title>
      this is Son for {{el.title}}
    </v-card-title>
    <v-text-field class="d-block pa-2" v-model="name" outlined label="Name"></v-text-field>
    <v-card-actions>

      <v-btn @click="add" class="d-block">
        <span>Add</span>
      </v-btn>
      <v-btn @click="dialog=false" class="d-block">
        <span>Close</span>
      </v-btn>
    </v-card-actions>
  </v-card>
    </v-dialog>

and this dialog inside loop and get this error after clicking button

Uncaught RangeError: Maximum call stack size exceeded.
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)
at VueComponent.onFocusin (VDialog.ts?d213:238)

can any one Help me with that error

Yazan Haffar
  • 313
  • 1
  • 2
  • 9
  • 1
    I think the problem may be caused by the `v-if` attribute in your dialog activator slot. Try removing that and see if it fixes it. If you want to hide the dialog button, maybe try moving the `v-if` to the dialog itself, i.e. `` – morphatic Apr 26 '20 at 20:28
  • 1
    There is a work around for v-dialog inside loop. [enter link description here](https://stackoverflow.com/a/62018919/12185738) – Gaurav Jun 16 '20 at 09:25

4 Answers4

46

Setting :retain-focus="false" on v-dialog helps too.

RomkaLTU
  • 3,683
  • 8
  • 40
  • 63
18

I just had the same error. Moving the dialog outside of my loop fixed the problem. You have to handle opening and closing your dialog yourself:

<v-dialog v-model="open"> ... </v-dialog>
<... v-for="thing in things">
    <v-btn @click="open = true"> ... </v-btn>
</...>
data() {
  return {
    open: false
  }
}
Dunk Fordyce
  • 196
  • 1
  • 4
5

This will help you too

<v-dialog v-model="dialog" max-width="900px" persistent :retain-focus="false">
 ...
</v-dialog>
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Mark Altiche
  • 69
  • 1
  • 1
1

on Nuxt adding <client-only> enclosing the element solved the problem

Nelson La Rocca
  • 173
  • 1
  • 9