Trying to use mouse to select multiple elements inside specific HTML element similar to how users can select multiple files and folders in Windows Explorer. Tested several libraries. In general, they work, but the tricky part is that each selectable element has a checkbox inside of it.
<div class="container">
<div class="selectable"><input type="checkbox" /></div>
<div class="selectable"><input type="checkbox" /></div>
<div class="selectable"><input type="checkbox" /></div>
</div>
To select elements with the mouse, each library adds mousedown
, mousemove
, mouseup
event handlers to the container
and it still works as displayed in the codepen below, mousedown
on container
normally co-exists with click
on checkbox.
https://codepen.io/artemiusgreat/pen/eYWzrQb
Apparently, it's not the case for Blazor, because I have the same markup as in the codepen above, the same events, but once I add mousedown
event to the container
using JS interop, all checkboxes inside container
stop working. With or without onclick
, checkboxes appear dead and non-clickable.
<!-- Checkbox outside of container works fine -->
<input type="checkbox" @onclick=@(e => SelectCollection(e)) />
<div class="container"> <!-- Inner checkboxes work only if container doesn't have "mousedown" handler -->
<!-- Checkbox inside of container with Blazor "onclick" does NOT work -->
<input type="checkbox" @onclick=@(e => SelectCollection(e)) />
<!-- Checkbox inside of container does NOT work even if it doesn't have any handlers -->
<input type="checkbox" />
</div>
Why???