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

Make form components uncontrollable #1683

Merged
merged 5 commits into from Aug 1, 2022

Commits on Jul 29, 2022

  1. implement uncontrolled form components

    A few versions ago we introduced compatibility with the native `form`
    element. This means that behind the scenes we render hidden inputs that
    are kept in sync which allows you to submit your normal form and get
    data via `new FormData(event.currentTarget)`.
    
    Before this change every form related component (Switch, RadioGroup,
    Listbox and Combobox) always had to be passed a `value` and an
    `onChange` regardless of this change.
    
    This change will allow you to not even use the `value` and the
    `onChange` at all and keep it completely uncontrolled.
    
    This has some changes:
    
    - `value` is made optional
    - `onChange` is made optional (but will still be called if passed
      regardless of being controlled or uncontrolled)
    - `defaultValue` got added so that you can still pre-fill your values
      with known values.
    - `value` render prop got exposed so that you can still use this while
      rendering.
    
    This should also make it completely compatible with tools like Remix
    without wiring up your own state.
    RobinMalfait committed Jul 29, 2022
    Configuration menu
    Copy the full SHA
    e3531ac View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0c41963 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    11c7b76 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0fd0493 View commit details
    Browse the repository at this point in the history

Commits on Aug 1, 2022

  1. Configuration menu
    Copy the full SHA
    de8474f View commit details
    Browse the repository at this point in the history