DEV Community

Discussion on: Accessible Color Pickers

supportic profile image
Supportic • Edited on

How do you access the values of the sliders when the input changed either via auto update or when clicking ok? Non of my event listeners work. Also maybe as enhancement, when you click outside, do not focus the input anymore. I think you made it that way so you keep the focus after pressing ESC while using keyboard only but the focus is not needed when clicking outside.

const logValue = (e) => {

const main = () => {
  const colorPickers = document.querySelectorAll('[data-colorpicker]');
  colorPickers.forEach((colorPicker) => {
    let pcr = new ColorPicker(colorPicker, colorPicker.dataset);


    colorPicker.addEventListener('input', logValue, false);
    colorPicker.addEventListener('change', logValue, false);
Enter fullscreen mode Exit fullscreen mode