-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TodoMVC example: editing middle of existing todo moves cursor to end of input #13
Comments
Good catch. I don't think we should have to hack so much for something so basic and I see that the React version works just fine. I'll think about this some more and see what changes we have to make to avoid this issue. |
So I had a series of long conversations today with some React users on the React IRC channel, it seems like making a simpler wrapper for the DOM form elements that involve text entry is the way to go - here's a sketch of how to make it work http://jsfiddle.net/cc324/5/. Just waiting to hear from a React Dev if there are any obvious mistakes here. |
@spicyj suggested the following http://jsfiddle.net/spicyj/Kmf9r/, this appears to leverage more of the existing API. |
Fix in master based on @spicyj's fiddle. |
Awesome 👍 |
Ah, I ran in to this when playing around with inputs. I was using sablono, where this particular issue isn't fixed yet. It's not great that it'll also have to be solved within libraries that don't depend on om. Do you think a library that takes hiccup forms in macros that convert to om.dom structure would be reasonable? I know @r0man wants to keep sablono dependency-free, otherwise I would say it would make sense there. |
In the TodoMVC example linked in the readme, there's a nasty input bug - when you edit an existing todo, if your cursor is anywhere before the end of the input, it will jump to the end after you enter a character.
This is, of course, because the input is getting completely reset on render. I'm currently implementing a widget with an input field in React, the solution I'm going with is:
update!
ed from theonChange
handler)did-update
hook to call.setSelectionRange cursor-pos cursor-pos
to reset back to the original positionThis works, but isn't ideal, and is certainly some nasty boilerplate to be attaching to every input. Maybe there could be a special
om/input
component that could handle resetting the cursor on every change?The text was updated successfully, but these errors were encountered: