question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposition about onInput/onChange

See original GitHub issue

Hi 😃

In ReactDom we can find:

function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
	if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) {
		return getInstIfValueChanged(targetInst);
	}
}

Why not adding an extra condition here like:

function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
	if ((!React.$$useRealOnChange && topLevelType === TOP_INPUT) || topLevelType === TOP_CHANGE) {
		return getInstIfValueChanged(targetInst);
	}
}

By checking React.$$useRealOnChange in this function, a user could add this line:

React.$$useRealOnChange = true;

anywhere in their code (before or after including ReactDom) to find back the more native behavior.

I’m sorry in advance if this proposition has already been proposed

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
roryokanecommented, Jan 9, 2022

Bump. This problem has not been solved yet: in React’s documentation for onChange there is still no mention of an alternative attribute (which would have a name like onChangeCompleted or onChangeNative) that uses the browser’s native onchange event handler.

2reactions
gaearoncommented, Sep 16, 2020

I think you overlooked a large part of the demo I provided.

I believe @rachelnabors was responding to the original post proposal. Yours is indeed different.

In which places would you like me to discuss my preferred solution of adding a backwards-compatible new attribute such as onChangeCompleted?

If you have a fully-formed proposal, http://github.com/reactjs/rfcs would be a good place to submit it as a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

oninput Event - W3Schools
The oninput event occurs when an element gets user input. This event occurs when the value of an <input> or <textarea> element is...
Read more >
In React, what's the difference between onChange and onInput?
It seems there is no real difference. React, for some reason, attaches listeners for Component.onChange to the DOM element.oninput event.
Read more >
When is onChange not the same as onChange?
A colleague raised a fair question, why doesn't an input element's onchange event type behave the same as React's onChange?
Read more >
"oninput" | Can I use... Support tables for HTML5, CSS3, etc
The input event is fired when the user changes the value of an <input> element, <select> element, or <textarea> element. By contrast, the...
Read more >
onchange event on input type=range is handled differently ...
Developers implement onchange rather than oninput because they test with the mouse and see it behaving the way they expect. In its current...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found