Materialize: Materialize Select change event fires even if value did not change

Created on 22 May 2017  路  6Comments  路  Source: Dogfalo/materialize

Description

If the user selects the same value that was already selected, the change event should not fire.

Repro Steps

JSFiddle showing the issue - open your JS console to see the messages logged.
https://jsfiddle.net/dgbnz/a26b35r1/3/

With the material select, pick the same value multiple times in a row - the change event fires every time. On the standard select it will only fire if a different value is chosen, which is the expected behaviour.

Select

Most helpful comment

Think about it like this. For you, it's quite simple to have nothing change if the same value is chosen. However, if someone else does needs an event when the same value is chosen, it will be incredibly difficult for that person to implement.

To counter your argument: frameworks like Materialize should not change the expected behavior of components that they are extending/modifying. The native SELECT component does not fire an onChange event when the user selected the same value. So, when a programmer has built something that works natively, it should not change its behavior when they add Materialize.

All 6 comments

Why is this a problem? Couldn't you just add an if statement to your code?

Yes, but why should I have to? Developers do not expect change events to fire if nothing actually changed... it's unexpected behaviour

Think about it like this. For you, it's quite simple to have nothing change if the same value is chosen. However, if someone else does needs an event when the same value is chosen, it will be incredibly difficult for that person to implement.

OK I'm not sure if it's actually a bug or if this is intentional behaviour - if it's intentional it should be documented in the Guide. Instead I had to figure out why my Angular Form was getting marked dirty and read through the implementation of material select to see why.

Duplicate of #4562

Think about it like this. For you, it's quite simple to have nothing change if the same value is chosen. However, if someone else does needs an event when the same value is chosen, it will be incredibly difficult for that person to implement.

To counter your argument: frameworks like Materialize should not change the expected behavior of components that they are extending/modifying. The native SELECT component does not fire an onChange event when the user selected the same value. So, when a programmer has built something that works natively, it should not change its behavior when they add Materialize.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heshamelmasry77 picture heshamelmasry77  路  3Comments

SoproniOli713 picture SoproniOli713  路  3Comments

ruslandzhumaev picture ruslandzhumaev  路  3Comments

samybob1 picture samybob1  路  3Comments

PhillippOhlandt picture PhillippOhlandt  路  3Comments