You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Managing the selection with something like a filtered controlled <input> is a huge pain right now -- if you do the simple thing of filtering the value in the onChange handler
@spicyj I was also wondering if you'd had any further movement on this. I'm actually just getting it in my normal controlled inpet when typing at a speed over 40 wpm (I happend to have a lot of other stuff going on at the same time in my app).
I did a lot of experiments on this a year or so ago. It's not terribly complex but the API becomes rather cumbersome or inflexible with if done naively:
A. Always only mutate text left/right/inside of selection, works as-is.
B. Selection as a property, {text: '', selection: [0, 1]}.
C. Text left/right/inside of selection as a property, {left: '', right: '', selected: ''}.
Problem is that only A is self-contained, but it does not behave (strictly) as intended if the value of the input is replaced entirely and is rather inflexible. The other 2 are actually incomplete. So what's really needed is probably a (somewhat) opaque type, provide a bunch of helpers for mutating it.
However, regardless of what the solution is. Know that in most browsers you end up discarding the undo history, in Chrome you actually end up corrupting it so undoing ruins what you wrote. So my current recommendation is to just stick with text-transform and preventDefault in onKeyPress.
Activity
montoya-azul commentedon Feb 19, 2015
Did you solve this?
GetContented commentedon Jun 14, 2015
@spicyj I was also wondering if you'd had any further movement on this. I'm actually just getting it in my normal controlled inpet when typing at a speed over 40 wpm (I happend to have a lot of other stuff going on at the same time in my app).
sophiebits commentedon Jun 15, 2015
None currently. If you have good ideas we'd love to hear them.
syranide commentedon Jun 15, 2015
I did a lot of experiments on this a year or so ago. It's not terribly complex but the API becomes rather cumbersome or inflexible with if done naively:
A. Always only mutate text left/right/inside of selection, works as-is.
B. Selection as a property,
{text: '', selection: [0, 1]}.C. Text left/right/inside of selection as a property,
{left: '', right: '', selected: ''}.Problem is that only A is self-contained, but it does not behave (strictly) as intended if the value of the input is replaced entirely and is rather inflexible. The other 2 are actually incomplete. So what's really needed is probably a (somewhat) opaque type, provide a bunch of helpers for mutating it.
Something like this perhaps:
However, regardless of what the solution is. Know that in most browsers you end up discarding the undo history, in Chrome you actually end up corrupting it so undoing ruins what you wrote. So my current recommendation is to just stick with
text-transformandpreventDefaultinonKeyPress.