Tuesday, 2 April 2019

HTML Color Input "oninput" event behaving differently on Chrome on Windows

On firefox, the oninput event of a color type input is fired while the OS color picker window is opened, everytime the user switches a color.

Now, on chrome it works exactly as the onchange event, it only fires if the actual color changes after pressing ok on the color picker window.

Is there a way to get the expected behavior on chrome? Is this a bug or a implementation choice?

Also, is there an event that fires even if the user doesn't change the color but only opens the color picker and presses ok? A onclick wouldn't be ideal as that would also trigger if the user presses cancel.

const colorInput = document.getElementById('color');
color.oninput = evt => {
  console.log('oninput');
}
<input id="color" type="color">

Edit : It seems that chrome and edge behave the same.



from HTML Color Input "oninput" event behaving differently on Chrome on Windows

No comments:

Post a Comment