First change event is reported too soon
See original GitHub issueWhat is the current behavior? Describe the bug On an inline editor, the first caracter you type (or the first modification you make) always trigger the change event. Susbequents modifications will only trigger the change event on focus out.
Please provide the steps to reproduce
- Create an inline editor with a listner to the editor “change” event. Put a console.log in there
- Type one caracter in the editor. The change event is fired.
What is the expected behavior? The first change should not be different from the other and should only trigger the change event on focus out. We’ve put an ugly work around for now as follow:
// firstChange and moreChanges are use to get around ab tinyMCE bug where you get a change event for the first modification (before the loose of focus)
// We want to ignore that unless it is the only changed made (moreChanges !== true)
var firstChange = true;
var moreChanges = false;
editor.on('change', function(ed) {
if (!firstChange) {
// save change to our model
moreChanges = true;
} else {
firstChange = false;
}
});
editor.on('blur', function(ed) {
if (!moreChanges && editor.isDirty()) {
// save that only change to our model
}
});
**Which versions of TinyMCE, and which browser / OS are affected by this issue? ** v5.6.2 Same on all tested browser (FF, Chrome and Edge)
Did this work in previous versions of TinyMCE? Unknown
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
javascript - Solution for on change doesn't work when input is ...
The onchange event only fires if the user changes the value of the input. It isn't supposed to fire if the input is...
Read more >Order of events for database objects - Microsoft Support
If you have changed data in a control, the BeforeUpdate and AfterUpdate events for both the control and the form occur before the...
Read more >Why is OnChanged event fired when no change occured?
The OnChange event should fire when the user presses enter or focus away from the component. Could you modify the application so that...
Read more >Leading Change: Why Transformation Efforts Fail
A few of these corporate change efforts have been very successful. ... But whenever some minimum mass is not achieved early in the...
Read more >Address change notification - FCSO
... how long does the provider/supplier have to inform Medicare of the “reportable event”? How should the change be reported?
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 FreeTop 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
Top GitHub Comments
@MissChocoe After discussing your case, the team agrees that that first
change
event should not fire. I’ll log a ticket internally for us to change that. However I did want to let you know that since we follow Semantic Versioning we may not be able to change it until 6.0, as it may be a breaking change for other customers. We will let you know when it is scheduled for a release.@mirkootter It sounds like your problem is more that there is no
change
event fired on focus out? From what we understand of your use case it should be, so that sounds like a bug. See this fiddle for an example of how this works (open the console, type into the editor then click elsewhere on the page - you should see the relevant events being fired). If you are seeing this problem, could you please make a new issue (so we can track the two separately) and please include the following details if possible:Now, the user decides otherwise and removes the '!' again.
- to clarify, you mean deleting or backspacing characters, not undoing them?I’ve also included in the fiddle I linked above a demo of the
beforeunload
event. From what you have said, we thought it may be helpful for your use case. Unfortunately, we’re unsure what would be best based on the information we currently have though.@mirkootter @MissChocoe Thanks for clarifying your use cases! I’ll discuss this with the team, and get back to you when we make a decision about what we want to do.