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

Enhancement: mirror cursor position/selection when picker is opened with focusInput: true #105

Closed momijizukamori closed 1 year ago

momijizukamori commented 1 year ago

Mostly because it feels like more intuitive behavior for end users? It's a quick change - after this line: https://github.com/mdbassit/Coloris/blob/main/src/coloris.js#L318 add colorValue.setSelectionRange(currentEl.selectionStart, currentEl.selectionEnd, currentEl.selectionDirection);. if the picker is configured with selectInput: true that still properly supersedes this and selects the entire input field.

mdbassit commented 1 year ago

I'm not sure what this is supposed to solve! Can you explain the issue you have?

mdbassit commented 1 year ago

I guess I didn't look closely. It looks to me like you want to mirror the selection from the original input field in the color picke's input field.

I will look into it.

momijizukamori commented 1 year ago

Yeah, basically by default, if you click into the original field and highlight, when you release the mouse button, you end up in the picker's input field with your highlight suddenly gone, which would be frustrating if you were trying to copy or paste a color from the field.

mdbassit commented 1 year ago

That is indeed a sensible addition. Will implement soon. Thank you for suggesting it.