I created a multiple select list box using the select tag as shown in the code below in Angular 5.
<select multiple id="MySelect">
<option>I am Option 1</option>
<option>I am Option 2</option>
<option>I am Option 3</option>
<option>I am Option 4</option>
<option>I am Option 5</option>
<option>I am Option 6</option>
<option>I am Option 7</option>
<option>I am Option 8</option>
<option>I am Option 9</option>
</select>
Now, the problem is that I can drag the mouse over the select box without selecting any option in actual as it will look like the image below.
From this image, one can conclude that all the first three options are selected in this list box but this is not the case in actual. To remove this dragging functionality, I added the preventDefault() function on mousedown and mousemove events as mentioned here.
Adding preventDefault() fixed this problem, but arised another problem. The problem was that on selecting one or more options in the list box, the background color of the selected option was gray instead of the default blue and when I inspected it in Chrome, it showed:
select:-internal-list-box option:checked {
background-color: -internal-inactive-list-box-selection;
color: -internal-inactive-list-box-selection-text;
}
To override this color, I used the !important along with the color-name but it was of no use.
Can someone please tell me what is the effective way to fix this problem in such a way that dragging selection will be disabled and the selected item's color will be blue? In case, if it is not possible, then can anyone please tell me an alternative component to use instead of this in Angular?