Skip to content

Controlled form resets focus on every keystroke #4544

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

Open
4 tasks done
joesaunderson opened this issue Apr 1, 2025 · 2 comments
Open
4 tasks done

Controlled form resets focus on every keystroke #4544

joesaunderson opened this issue Apr 1, 2025 · 2 comments
Labels
awaiting response bug needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc.

Comments

@joesaunderson
Copy link

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

When using the form in controlled mode, every keystroke into the form resets the forms focus.

Example:

const App = () => {
  const [formData, setFormData] = React.useState(null);
  return (
    <Form
      schema={{ type: 'string' }}
      formData={formData}
      onChange={(e) => setFormData(e.formData)}
      validator={validator}
    />
  );
};

Expected Behavior

It should maintain the focus state of the element.

Steps To Reproduce

Run the above code, type into the form.

Environment

React 18

Anything else?

Linked to #391 (changing to controlled form as a workaround due to the attached issue).

@joesaunderson joesaunderson added bug needs triage Initial label given, to be assigned correct labels and assigned labels Apr 1, 2025
@nickgros
Copy link
Contributor

nickgros commented Apr 4, 2025

@joesaunderson I cannot reproduce this in this CodeSandbox, is there something I failed to capture here?

@nickgros nickgros added awaiting response needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc. and removed needs triage Initial label given, to be assigned correct labels and assigned labels Apr 4, 2025
@joesaunderson
Copy link
Author

@joesaunderson I cannot reproduce this in this CodeSandbox, is there something I failed to capture here?

Hey, the only difference is we're styling the form, reproducible example (with no fields being overriden, but the methods the same)

https://codesandbox.io/p/devbox/rjsf-v5-4544-reproduction-forked-dm5cmw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response bug needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc.
Projects
None yet
Development

No branches or pull requests

2 participants