-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QMenu with auto-close stops QItem / QCheckbox working correctly #17735
Comments
Hi, You need to manually stop the "click" event propagation on the items that you do not want to auto-close the menu. <q-checkbox @click.stop ... |
I do want to auto-close the menu. The behaviour in the codepen is unchanged (I added your |
I'm now seeing that in your example, the label attached is not part of the QCheckbox. So you might be clicking the item label and seeing that the state does not change. So: <q-item tag="label" @click.stop v-close-popup> |
I'm still not sure what's wrong with my explanation, unless the answer is just that 'auto-close doesn't work when using I'm not sure what I did wrong so that "the label attached is not part of the QCheckbox". I used the code from here If it's behaving as expected, it didn't seem to be documented anywhere... |
Nothing wrong with your usage. I was just explaining why I initially mentioned to put the I agree that this is a lot of repetition in adding |
@rstoenescu I suggest we document this behavior/limitation instead, then. Would that be fine? |
@rstoenescu agree with all your points—I was just confused initially because the QMenu If "use v-close-popup" when the menu contains QItem / QCheckbox combinations is the solution, that's fine, and documenting it in QMenu And, in trying to work through all that, this pattern seems to work even better, in that it doesn't require separate click handling. In effect, just use the QCheckbox to show the state: <q-item v-for="(option, index) of setting.options" v-close-popup :key="index" clickable @click="option.value.value = !option.value.value">
<q-item-section side>
<q-checkbox :model-value="option.value.value" class="no-pointer-events"></q-checkbox>
</q-item-section>
<q-item-section>{{option.label}}</q-item-section>
</q-item> |
What happened?
A QMenu with
auto-close
set does not functions correctly when the menu contains a QItem / QCheckbox combination as described here.What did you expect to happen?
The checkbox model would be updated when clicking either the checkbox or item, and the menu would be closed.
Reproduction URL
https://codepen.io/dsl101/pen/bNbeeGm?editors=1010
How to reproduce?
auto-close
—clicking the item or checkbox updates the model value correctlyauto-close
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Components (quasar), Directives (quasar)
Platforms/Browsers
Firefox
Quasar info output
No response
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: