Skip to content
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 is losing focus , when wrapped with VariableSizeList #755

Open
pst37 opened this issue Feb 12, 2024 · 2 comments
Open

Input is losing focus , when wrapped with VariableSizeList #755

pst37 opened this issue Feb 12, 2024 · 2 comments

Comments

@pst37
Copy link

pst37 commented Feb 12, 2024

I have wrapped a input element inside VariableSizeList. When there is change in input component, the input component is losing focus , because whole component is getting remounted or i can say react is re-creating whole new tree.

I have added the example here.
Example here

Steps:-
1.) Open Element tab in dev-tools
2.) type anything in any input box

You will notice the wrapper of all new input is getting updated ...

@Dimitrov-Codes
Copy link

I am facing the same issue . Are there any workarounds to this??

@h7y
Copy link

h7y commented May 2, 2024

Moving the renderer 👇 to a separate function as shown in the docs would fix this :)

{({ index }) => (
  <div className="test">
    <input
      type="text"
      placeholder="search"
      value={searchText[index]}
      onChange={(e) => onChange(e, index)}
    />
  </div>
)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants