Click event triggered for the option even when it is already selected in material select
Expected Behavior
When selecting an option which is in selected state, should not trigger onchange event again and again
Current Behavior
When selecting an option which is in selected state, triggering onchange event whenever selected
Steps to Reproduce (for bugs)
- Navigate to http://materializecss.com/forms.html#select
- Register the following onchange event in browser console by opening developer tools
- $(document).on('change','#select',function(){alert('1');});
- Now select an option from material select which was converted by calling material_select() method. Not browser default. Alert will show 1.
- Now again select the option which is already selected. Again onchange event triggered and alert shown.
Your Environment
- Version used: v0.98.1
- Browser Name and version: Firefox 56.0 64 bit
- Operating System and version (desktop or mobile): Desktop
I think that is not an undesirable bug. One way to fix the problem would be to have a global variable which is going to store current value from the select. Whenever onchange is triggered, you can do a check if the value is same as the old value. If true then do something else.
That is OK. I Agree. This can be accepted when the number of dropdowns are limited. What if I have n number of pages and n number of dropdowns in each page?
Alternatively we should not react on the selected list item. I will see if this issue is reproducible in v1 Branch. If yes will fix it