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.
Unfortunately, this is a Windows limitation. The ChooseColor
function is responsible for that dialog and it only outputs the color information when the user closes the dialog.
If you want the user to be able to change colors live, consider using a library like jscolor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With