reactpy icon indicating copy to clipboard operation
reactpy copied to clipboard

Set React's onChange property for input elements if its not provided

Open JamesHutchison opened this issue 10 months ago • 2 comments

Description

Add onChange to input elements

Checklist

Please update this checklist as you complete each item:

  • [ ] Tests have been developed for bug fixes or new functionality.
  • [ ] The changelog has been updated, if necessary.
  • [ ] Documentation has been updated, if necessary.
  • [ ] GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

JamesHutchison avatar Mar 08 '25 01:03 JamesHutchison

It doesn't seem like there should be any side effects to this change since it is aligning the behavior when on_change is and is not provided

JamesHutchison avatar Mar 08 '25 01:03 JamesHutchison

Needs regression tests and fixes for failing tests

Archmonger avatar Mar 08 '25 02:03 Archmonger

After some additional thought, I'm going to close this. This PR tricks ReactJS into thinking everything is a controlled input, which negates some safety/guardrails that exist in the React client.

The more healthy solution is to verbosely communicate to the developer that they are utilizing an uncontrolled input when ReactPy is in debug mode:

  • https://github.com/reactive-python/reactpy/issues/890

Archmonger avatar May 31 '25 23:05 Archmonger