StreakYC / react-draggable-list

React component for a list of draggable collapsible items
MIT License
319 stars 48 forks source link

the input field inside the template loses focus after typing a character #53

Open akbarism opened 1 year ago

akbarism commented 1 year ago

i am using react hooks in this case, everything is running smoothly before any input text in the template, looks like when typing a character the component re-renders, therefore the input field loses focus, is there any solution to this problem?

it seems it will really take a long time if I look for another package

By the way, I really like your work, it's very easy to understand than other packages!

ljmzbigsmart commented 1 year ago

I am having the same problem with this package, did you manage to solve it @akbarism? Tried multiple ways (taking the template component out to another function and other "hacky" ways, but same problem.

Macil commented 1 year ago

This type of issue usually happens from not using the itemKey prop correctly. A component merely re-rendering shouldn't cause it to lose state. It might be that you have the component's key changing in response to the user input, which will cause it to be freshly remounted.