Describe the bug
When a component like a QItem with the clickable prop or a QChip with the removable prop is clicked inside a QMenu and, as a result of that click, the QItem or QChip clicked is removed from the DOM, the QMenu is closed.
When one of the described inner elements is clicked, they send a focusin event. Specifically, a clickable QItem inside a QList calls the focus() method on the $refs.blurTarget element. The click-outside directive applied to the QMenu, which is listening to the focusin event, executes the handler to close the QMenu with a timeout of 200ms. If the click event removes the element from the DOM, that timeout means the target of the focus event is not found inside the QMenu anymore when the handler is run, and this makes the QMenu close.
I have tried to circumvent this behavior in a few different ways.
persistent works, as it does not apply the click-outside directive to it, but I do want to be able to hide it when I do actually click outside of it.removable QChips, as the 'remove' event is not native.Codepen/jsFiddle/Codesandbox (required)
https://jsfiddle.net/cto4q5gf/14/
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The list inside the menu should hide, but the menu should still remain open.
Platform (please complete the following information):
OS: MacOs
Node: v13.11.0
Yarn: 1.22.4
Browsers: Chrome 80.0.3987.149
Additional context
Quasar v1.9.3
You can:
Hey @pdanpdan, thank you so much for your help, really appreciate it.
Regarding your solutions:
focus() function is called in the QItem even if I also call it somewhere else. I tried focusing something else in my updated jsfiddle (https://jsfiddle.net/w4nh7vmq/8/) but I see the problematic flow still being reproduced. What you say sounds good, could I bother you to please elaborate it so I can try and fix it this way?ou must put a tabindex attr on the element you want to focus: https://jsfiddle.net/yo3fwxad/7/
And that did the trick! It's working as expected now. Thanks a lot, @pdanpdan, really appreciate your help.
I think we should close this - it's nothing I can think of that we can do at framework level.
If anybody has an idea please post here.