No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to submit a dialog window when pushing "Enter key"?

    Help
    3
    6
    2984
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      Zyme last edited by

      Anyone know how I can submit my form in my dialog when I hit Enter?

      1 Reply Last reply Reply Quote 0
      • fsgiudice
        fsgiudice last edited by

        Same question here

        1 Reply Last reply Reply Quote 0
        • rstoenescu
          rstoenescu Admin last edited by

          const catchEnterKey = evt => {
              if (evt.which === 13 || evt.keyCode === 13) {
                dialog.close()
              }
            }
          window.addEventListener('keyup', catchEnterKey)
          
          const dialog = Dialog.create({
            ...........,
            onDismiss: () => { window.removeEventListener('keyup', catchEnterKey) }
          })
          

          Notice that when pressing ENTER key, no matter where the focus is in Dialog, will close it.

          1 Reply Last reply Reply Quote 0
          • fsgiudice
            fsgiudice last edited by

            Thank you @rstoenescu

            1 Reply Last reply Reply Quote 0
            • Z
              Zyme last edited by Zyme

              Thanks it almost works but I have a click handler on my button:

              this.dialog = dialog.create({
              ...
                         form: {
                          name: {
                            type: 'text',
                            label: 'New name',
                            model: basename
                          }
                        },
                       buttons: [
                       {
                            label: 'Rename',
                            color: 'positive',
                            outline: true,
                            // Click handler
                            handler: (data) => {
                              this.rename(data)
                            }
                          },
                          {
                            label: 'Cancel',
                            color: 'red',
                            outline: true
                          }
                        ],
                       onDismiss: () => { window.removeEventListener('keyup', this.catchEnterKey) }
              })
              

              Which means this.rename does not fire when the dialog closes on Enter. And I can’t pass data to onDismiss

              1 Reply Last reply Reply Quote 0
              • rstoenescu
                rstoenescu Admin last edited by

                @Zyme Added form data to close() and onDimsiss() on edge (will get into v0.14.7), so check that 😉
                Thanks for pointing this out.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post