craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

"Leave without saving changes" when CTRL+S followed by console error "Uncaught in promise" #4761

Closed nitech closed 5 years ago

nitech commented 5 years ago

Description

Sometimes, when saving an entry by pressing CTRL+S, I get a message asking if I really want to leave without saving. I say "of course not" - and when I then try to press "Update Entry", nothing happens. The console says the following:

Uncaught (in promise) undefined at Craft.js:13206

image

Coming from this code in Craft.js:

image

I refresh, click "update entry" and things work fine. It also seems that the changes actually were saved to the draft.

Additional info

Admin Bar 3.1.8.1 CKEditor 1.0.0-beta2 CP Field Inspect 1.0.6 Feed Me 4.1.2 HTML Cache 1.0.15 Imager 2.1.10 Kint 1.0.0 Mailchimp Subscribe 3.0.0 Migration Assistant 3.1.3 NSM Fields 0.0.14 Navigation 1.1.13 Neo 2.4.2 Queue Manager 1.1.0 Redactor 2.3.3.2 SEO 3.6.2 Section Field 1.1.0 Super Table 2.2.1 Typed link field 1.0.19 oEmbed 1.1.6

brandonkelly commented 5 years ago

…I get a message asking if I really want to leave without saving.

This shouldn’t be possible as of Craft 3.2.8. Can you try running composer install, then clear out your web/cpresources/ folder, and also clear out your browser caches?

nitech commented 5 years ago

Yeah, it's actually the browser asking. It happens only when I click CTRL+S - not when I click the save-button.

image

The deceitful thing about this message is that if you click "Cancel", your element won't be saved - and thus you will lose all changes. If you however click "Leave", the changes will actually be saved.

Perhaps this is a JS beforeunload-event being triggered and handled on one of the Field plugins I'm using?

brandonkelly commented 5 years ago

Craft sets the beforeUnload event, so most likely it’s coming from that. But it should only be happening when you are leaving the page with unsaved changes; not when you are submitting the form (whether via the button or Ctrl+S).

nitech commented 5 years ago

Caused by bug in the Neo Fields plugin. Fixed in version 2.4.5 https://github.com/spicywebau/craft-neo/releases/tag/2.4.5