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.

First change event is reported too soon

See original GitHub issue

What 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

  1. Create an inline editor with a listner to the editor “change” event. Put a console.log in there
  2. 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:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
metricjscommented, Jan 22, 2021

@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:

  • A fiddle that demos how to replicate your problem. You can use our Fiddle site, or Codepen or any similar site.
  • Details about any integrations you’re using (e.g. React).
  • What happens when your users “leave the editor” (e.g. Are they clicking a button to navigate elsewhere? Are they closing a popup?)?
  • You said Now, the user decides otherwise and removes the '!' again. - to clarify, you mean deleting or backspacing characters, not undoing them?
  • Anything else that might help us replicate your issue.

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.

0reactions
metricjscommented, Jan 22, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

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