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

    Trigger q-select with other keys aside from the default ENTER

    Framework
    2
    4
    330
    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.
    • J
      johnm last edited by

      I am using the q-select as an input field where users can enter values.

      https://quasar.dev/vue-components/select#Create-new-values

      Currently, the @new-value listener is triggered with using the ENTER key.

      How can I modify so that it also listens to other keys such as tab or escape?

      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @johnm last edited by

        @johnm https://codepen.io/metalsadman/pen/jOMexgy

        1 Reply Last reply Reply Quote 1
        • J
          johnm last edited by johnm

          @metalsadman I’d like to rephrase a little bit. Given your codepen code, how can I let TAB trigger createValue? Currently, only ENTER can trigger that function.

          My use case is I want to validate the value before calling done() or before adding the input value as a chip to the q-select.

          https://codepen.io/metalsadman/pen/jOMexgy

          metalsadman 1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman @johnm last edited by metalsadman

            @johnm was kind of already doing that in the tabAdd handler if(this.holder === '') return, tho you can make generic validator function that can call to validate both handler. ie.

            
            function someValidator (val) {
             ...
             return 
            }
            
            tabKeyHandler() {
              if(!someValidator(holder)) return
              ...
            },
            newValueHandler(val, done) {
              if(!someValidator(val)) return
              ...
              done(...)
            }
            

            or just use one event listener, the tab one.

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