GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 393 forks source link

Minor issue with a spurious "Leave page" warning #510

Closed cyclaero closed 4 years ago

cyclaero commented 5 years ago

Please may I suggest to change line 9056 of content-tools.js from:

if (_this._state === 'editing' && ContentTools.CANCEL_MESSAGE) {

to:

 if (_this._state === 'editing' && _this.history && _this.history._snapshotIndex && ContentTools.CANCEL_MESSAGE) {

This would fix the problem that I sometimes see the "Leave page" warning when the editor has been started, and nothing has been touched, though, and I leave the page. With this in place, the warning appears only if really something has been edited.

anthonyjb commented 5 years ago

Hey @cyclaero makes a lot of sense thanks for the suggestion.

anthonyjb commented 4 years ago

@cyclaero just wanted to thank you for raising this issue and submitting the relevant changes. The code has been pushed now and will be in the next release (later this evening).