prevent click propogation of options
See original GitHub issueTo Reproduce
<!-- method should never be called when clicking an option -->
<div @click="method">
<!-- this should prevent click propogation of options -->
<div @click.stop>
<v-select .../>
</div>
</div>
Steps to reproduce the behavior:
- Have a click listener on an item wrapping v-select
- Wrap v-select with a div and use
@click.stop
- Click the dropdown
- Click an option
Expected behavior
Clicking an option should not trigger the parent click event, since it is a child of the div that has @click.stop
. However, a click event is triggered. One is not for the dropdown itself, maybe because it’s not dynamic? In inspector, the dropdown options are contained within the div, but seem to float outside of it.
@mousedown
seems to work for my use case, maybe because @mousedown.prevent
is used here?
It would be great if there was a way to also prevent clicks from propogating.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:11
Top Results From Across the Web
Event.stopPropagation() - Web APIs | MDN
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Read more >How to prevent click event propagation - angular dart
1 Answer 1 · Thanks Ted. While this is the way to stop propagating events, it is not easy to apply, especially with...
Read more >stopPropagation() Event Method - W3Schools
The stopPropagation() method prevents propagation of the same event from being called. Propagation means bubbling up to parent elements or capturing down to ......
Read more >event.stopPropagation() | jQuery API Documentation
These handlers, therefore, may prevent the delegated handler from triggering by calling event.stopPropagation() or returning false . Example: Kill the bubbling ...
Read more >The Dangers of Stopping Event Propagation - CSS-Tricks
Stopping propagation should be thought of like canceling an event, and it should only be used with that intent. Perhaps you want to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has posed an interesting problem.
Say you have a modal with a backdrop, and user can click backdrop to close modal. In that modal, you also have a dropdown menu, whose length exceeds that of the modal.
In previous versions of vue-select, this did not seem to be an issue. But now, since the click event of an option is bubbled upwards, the modal’s backdrop gets the click, and the modal closes.
I dont know if solve the issue, in a similar situation adding
@click.stop=""
preserve the select function without propagating the click event to outer components