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

    q-select how to close when not in focus

    Help
    4
    8
    1162
    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.
    • D
      darkshifty last edited by

      I’m trying to work with Q-Select the end user requested it to close when the mouse isn’t on the select or dropdown. What is the best way to archieve this Quasar wise?

      1 Reply Last reply Reply Quote 0
      • F
        felek last edited by

        I think there is method called hidePopup. You will have to implement event listener mouse leave and then hidePopup.

        dobbel 1 Reply Last reply Reply Quote 1
        • dobbel
          dobbel @felek last edited by

          by using a ref on the q-select you can call the hidePopup method.

          1 Reply Last reply Reply Quote 0
          • D
            darkshifty last edited by darkshifty

            Yeah this is exactly the problem, i can only set the mouse leave to the select element. The function isn’t attached to the options.

            <q-select standout="bg-red text-white"
                      bg-color="white"
                      class="q-pa-xs"
                      square
                      dense
                      v-model="category"
                      v-on:mouseleave.native="doSomething"
                      :options="categoryOptions"
                      label="Catalog" />
            

            so once the user goes out of the select area (to select an option) mouse leave is fired. However, I wish to close the dropdown once the mouse leaves the selectbox and options.

            dobbel 1 Reply Last reply Reply Quote 0
            • dobbel
              dobbel @darkshifty last edited by dobbel

              @darkshifty

              Ajh yes I understand what you are trying to do, I will think about a solution.

              But from experience I can tell that this behavior is VERY annoying (and uncommon), because if the user will just slightly get out of bounds of the expanded options or select the whole select will close unexpectedly.

              1 Reply Last reply Reply Quote 0
              • D
                darkshifty last edited by darkshifty

                I agree, sadly the business wants this so I have to jump some loops. I will have a look at q-menu, maybe I can emulate the same with the desired behaviour.

                Dankjewel

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

                  @darkshifty try using the option slot and inhibit the event there, but yeah I could see qmenu doing just as well, qselect’s options is a qmenu + qlist/qitems under the hood.

                  1 Reply Last reply Reply Quote 1
                  • D
                    darkshifty last edited by

                    @metalsadman thank you, that is a great solution! for reference, I’ve created the following:

                    methods: {
                        mouseEnter() {
                            this.mouseLeft = false
                        },
                        mouseLeave() {
                            this.mouseLeft = true
                            setTimeout(() => {
                                if (this.mouseLeft) {
                                    this.$refs.categorySelect.hidePopup()
                                    this.$refs.categorySelect.focused = false
                                }
                            }, 200);
                        }
                    },
                    
                    <q-select standout="bg-red text-white"
                              ref="categorySelect"
                              bg-color="white"
                              class="q-pa-xs"
                              square
                              dense
                              v-model="category"
                              :options="definitions.categoryOptions"
                              label="Catalogus">
                        <template v-slot:option="{ itemProps, itemEvents, opt, selected, toggleOption }">
                            <q-item v-bind="itemProps"
                                    v-on="itemEvents"
                                    @mouseenter="mouseEnter"
                                    @mouseleave="mouseLeave">
                                <q-item-section>
                                    <q-item-label v-html="opt"></q-item-label>
                                </q-item-section>
                            </q-item>
                        </template>
                    </q-select>
                    
                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post