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
Input elements lose their value while being dragged #63
Comments
Are you storing the element's value in state / your store? |
@JakeSidSmith Not currently it was not required for the component I was writing. I would only fetch the value on submit through a Is there anyway that non state related values can be restored to the temporary "dragging" element. Like offer up "dragstart" and "dragend" methods so that we could possible handle these things ourselves without having to store all input values in state. |
Ideally you should be storing your values in some kind of store, but I'm not certain that would fix the issue. I'm a little surprised this is a problem, I don't see why the value would be lost, but I'll take a look and see if I can fix it. :) |
I managed to get it working using a super hacky properties trick. I setup a bunch of function to store the value in the parent state and pass the value in as an attribute on the "item" object. But it is super hacky and it would be better if I didn't have to do it 👍 |
Hey, @MarshallOfSound have had a play around and came up with this: #64 Could you give it a test on your project? Should solve the issue. :) Also fixes a few other potential issues. |
@JakeSidSmith It appears to now keep the input value while being dragged 👍 But now when dragging it doesn't appear to actually reorder the elements. It visually reorders while dragging, but when you release everything reverts. |
Ah crap. Was working OK for me. Are you using the indices to reorder components yourself, or the reordered list that is provided in the callback? |
Neither? Before when I dragged and dropped this utility reordered the components for me. Now it does not? |
Ah yeah, it mutated the list you passed in, which I realised was a bad idea. Now you've gotta use some of the arguments in the callback. :) The last one is the new list. See the readme. |
Hmmm, interesting. So all I have to do is hold the list in my state and setState in the callback. I actually like that more 👍 Gimme a sec to test 😄 |
Yep, that branch fixes the input value issue 👍 Thanks for the quick response 😸 |
Worth pointing out though that this fix would be a breaking change for people not handling the callback like me and just letting the mutation happen 😢 |
Yeah, I guess I'll make some other improvements and release a new major version. There's a few thing to clean up anyway. :) |
@MarshallOfSound Was #66 a sufficient fix for you? Would like to get it merged & close this issue if possible. :) |
Update: just released See the readme after installation, there's been a considerable change to the interface. This issue is fixed for single lists in the version 3 alpha. |
Closing due to lack of response. |
If the template element has an input element when it is dragged the value is lost and brought back again when the drag is released. As far as I can tell this is due to how the reorder component renders a new "template" element for each drag.
The text was updated successfully, but these errors were encountered: