stylo icon indicating copy to clipboard operation
stylo copied to clipboard

Selection mark disappear

Open zRains opened this issue 2 years ago • 4 comments

before i customs text color

image

when i click the input element, selection mark disappear, but the color can still change normally.

image

actually, click the toolbar will take same effect.

zRains avatar Apr 10 '22 03:04 zRains

Not sure how to solve this. When user focus the input field, the selection is applied to the input. Therefore the text is not displayed as selected anymore unless the user enter a valid color in which case I redo the selection and modify the color. This does not happen in your example because the text entered is not a valid color.

So yeah, not sure exactly how to solve it. If you have an idea, go for the PR 🚀

peterpeterparker avatar Apr 10 '22 07:04 peterpeterparker

This is how you solve it. Notice you can highlight text, click the input area causing focus to be lost, while keeping text highlighted.

https://jsfiddle.net/cp6L291g/135/

I am not good enough to implement such a solution myself, but in case you actually want to solve that the solution is at provided link. :)

viraladmin avatar May 02 '22 16:05 viraladmin

This is how you solve it. Notice you can highlight text, click the input area causing focus to be lost, while keeping text highlighted.

https://jsfiddle.net/cp6L291g/135/

I am not good enough to implement such a solution myself, but in case you actually want to solve that the solution is at provided link. :)

Thanks a lot. Unfortunately jsfiddle was blocked in my country. I fixed it through Selection and Range, with a lot break changes.

zRains avatar May 05 '22 13:05 zRains

https://jsfiddle.net/cp6L291g/135/

Unfortunately this isn't a valid solution for Stylo. This gist copy the selection and modify the DOM when the user is typing within the input field to give the feeling the text is still selected.

peterpeterparker avatar May 05 '22 14:05 peterpeterparker