peterpeterparker/stylo

Selection mark disappear

zRains opened this issue · 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.

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 🚀

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. :)

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.

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.