When your page contains a multiple select and a dropdown, initializing the select before the dropdown by following the current documentation makes the multiple select close when an option is clicked.
It should not matter in which order a component is initialized
Initializing a FormSelect marked with multiple before initializing Dropdown with the selector .dropdown-trigger as currently documented at https://materializecss.com/dropdown.html#initialization closes the select when an option is clicked.
dropdown-trigger for selects,dtopdown-trigger for dropdown or(This seems to mainly be a documentation problem but it would be nice if the initializers would not interact at all)
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css">
<div class="row">
<div class="input-field col s12 m8 xl6">
<select name="notWorking" required multiple>
<option value="" disabled>Choose your option</option>
<option value="1">Opt1</option>
<option value="2">Opt2</option>
<option value="3">Opt3</option>
</select>
<label>A multiselect that does not work</label>
</div>
<div class="input-field col s12 m8 xl6">
<select name="working" required multiple>
<option value="" disabled>Choose your option</option>
<option value="1">Opt1</option>
<option value="2">Opt2</option>
<option value="3">Opt3</option>
</select>
<label>A working multiselect</label>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
M.FormSelect.init(document.querySelector("select[name='notWorking']"));
M.Dropdown.init(document.querySelectorAll('.dropdown-trigger'));
M.FormSelect.init(document.querySelector("select[name='working']"));
});
</script>
Also available as a codepen at https://codepen.io/anon/pen/djERMm?editors=1010
Still a problem in 1.0.0
Still a bug in 1.0.0 !!
Most helpful comment
Still a problem in 1.0.0