mdbassit / Coloris

A lightweight and elegant JavaScript color picker. Written in vanilla ES6, no dependencies. Accessible.
https://coloris.js.org/examples.html
MIT License
443 stars 58 forks source link

Coloris does not call the onChange event if the mouse is released outside the colorArea #153

Closed ut4 closed 1 month ago

ut4 commented 1 month ago

Describe the bug The picker does not trigger the onChange event when the mouse is released outside the colorArea.

To Reproduce Steps to reproduce the behavior:

  1. Open the picker
  2. Press the mouse down inside the colorArea
  3. Drag the mouse cursor outside the colorArea
  4. Release the mouse
  5. onChange is not triggered

Expected behavior onChange should be triggered, just as it does when the mouse is released inside the colorArea.

mdbassit commented 1 month ago

Hello, thank you for reporting.

onChange will fire whenever the color value changes. In this case, the last mousemove will trigger onChange even if the mouseup on document doesn't trigger it. Is this not enough for your use case? Could you describe a case where this is not enough?

ut4 commented 1 month ago

I don't think my use-case is relevant in this matter. I created this bug report mainly because if a callback is defined in the library's API, it should work consistently. In this case, it sometimes works and sometimes doesn't. The mouseup event should either always trigger the onChange event or never trigger it at all, no? You can of course reject and close this bug report if you don't agree, no harm done 😊

mdbassit commented 1 month ago

When you say "it sometimes works and sometimes doesn't", what is the practical deficiency you experience when "it doesn't work"? I don't mind fixing a real bug that has a real effect in the real world, but I'm not going to waste my time chasing after some misplaced idea of consistency. Please describe a problem you are encountering with this color picker or close this issue.

Thanks.