facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
227.32k stars 46.37k forks source link

Bug: onChange is not triggered when the 'input' event listener changes the target's value. #29036

Open timbo-dev opened 4 months ago

timbo-dev commented 4 months ago

React version: 18.3.1

Steps To Reproduce

  1. Create a root component.
  2. Insert an input tag that contains an onChange prop.
  3. Call useRef to get the input.
  4. In a useEffect call, add an event listener with "input" as the listener.
  5. Observe how the onChange prop will not be triggered.

Link to code example

Vanilla JavaScript example

Current Behavior

After typing some characters into the input, the input event listener is triggered, changing the target.value property. However, for some reason, the onChange prop is not being triggered. If we comment out the line that changes the target.value, both listeners are triggered as expected.

Expected Behavior

The onChange prop should be triggered after the input event listener changes the target.value property.

purvish-dhameliya commented 4 months ago

assign to me

timbo-dev commented 3 months ago

@purvish-dhameliya I don't have permissions for it.

github-actions[bot] commented 3 weeks ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

timbo-dev commented 3 weeks ago

bump