onChange fires when value is changed programatically
See original GitHub issueonChange
is called when the Codemirror component receives a new value when rendering.
Test case: https://gist.github.com/insin/9e507894f3858028c7e5 Live version: http://bl.ocks.org/insin/raw/9e507894f3858028c7e5/
Every call to onChange is alert()
-ed, Clicking the “Change value” button changes the value in the component’s state.
Just got bit by this using Redux, as updating some state which was being passed to Codemirror resulted in another dispatch firing via onChange
, resulting in old state being retained. Worked around it myself by having onChange
check if it received the same value as was being used for rendering, but is this behaviour something that’s possible to control, or it is a consequence of how Codemirror itself is implemented?
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How do I programmatically force an onchange event on an ...
This technique only works if the change handler was attached by setting "onchange". It does not generate a 'real' event that triggers w3c...
Read more >Programatically changing input value does not fire Onchange ...
Whenever the value is changed, on change event should be fired irrespective of the way the value was changed.
Read more >How to fire "onchange" programmatically ? - MSDN - Microsoft
The onchange-event only fires when the user changes the value of a textbox. When the value of this textbox has been changed programmatically...
Read more >Simulate React On-Change On Controlled Components
Manually trigger onChange when component is updated programmatically ... in React now dedupe's change events so they don't fire more than once per...
Read more >Onchange event gets fired when value is set programmatically...
You may put below lines to overwrite existing funcationality of your control. var cntr=Xrm.Page.getControl("<your control Id>");. cntr.setAttribute("onchange", ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The example doesn’t really work for me (some errors in the console). However, the
change
event from CodeMirror instance has a second argument which describes the change. If value comes fromsetValue()
call, thenchange.origin == 'setValue'
, so I think that may be used to differentiate between the changes.Hey all. I too was struggling with some related issues and decided to roll another wrapper for this at react-codemirror2. No external deps, state free, and works well for my use case. Please give it a look if you are feeling adventurous. I’d like to actively maintain it moving forward. I’m also looking for suggestions to craft it in the best fashion moving forward, so feel free to open up an issue with any wants/tips/etc you may want. Thanks!