elementor / elementor/elementor

Site Settings can never be saved: publishDraftComponentsInPageBeforeSave throws "Cannot read properties of undefined (reading 'toJSON')"

Open
#36,975 2 comments 0 reactions 0 assignees View on GitHub
status/awaiting_triage
Dominant language
PHP
Stars
7.1k
Forks
1.6k
Avg merge
1d 5h
Merged PRs (30d)
193

Description

### Description

Opening the Default Kit document in the editor and changing anything under **Site Settings** (e.g. Global Fonts), then clicking "Save changes", does nothing at all: no HTTP request is sent, no error is shown in the UI, and the save button stays in its "unsaved" state indefinitely.

The console throws on every save attempt:

```
TypeError: Cannot read properties of undefined (reading 'toJSON')
at ElementorCommonApp.beforeSave [as __beforeSave]
(elementor/assets/js/packages/editor-components/editor-components.min.js?ver=4.2.2:1:62279)
at Save. (elementor/assets/js/editor.min.js?ver=4.2.2:2:113180)
```

The exception happens in a `beforeSave` hook, i.e. **before** the save payload is built, so the request is never issued and the failure is completely silent to the user.

It reproduces deterministically through the internal API:

```js
await $e.run('document/save/default')
// -> TypeError: Cannot read properties of undefined (reading 'toJSON')
```

`window.elementorV2.editorComponents` exports `publishDraftComponentsInPageBeforeSave`, which is the `beforeSave` hook in the stack. The Kit document has no components container, so the hook appears to dereference an undefined object and throw.

Impact: Global Fonts, Global Colors, Custom CSS and every other Site Setting are impossible to change. The whole design system of the site is frozen.

### Steps to reproduce

1. Open the Default Kit in the editor: `/wp-admin/post.php?post=&action=elementor`
2. Go to Site Settings > Global Fonts
3. Change any font family (e.g. Primary from Roboto to Marcellus)
4. Click "Save changes"
5. Open the browser console and/or the Network tab

Result: the console shows the TypeError above, no request is sent, and `/wp-content/uploads/elementor/css/post-.css` still contains the previous font families after a hard refresh.

### Expected behavior

Clicking "Save changes" in Site Settings should persist the kit and regenerate `post-.css` with the new values. If a beforeSave hook fails, the editor should at minimum surface an error to the user instead of silently doing nothing.

### Elementor System Info

```txt
== Server Environment ==
Operating System: Linux 6.1.0 (Debian 11) x86_64
Software: Apache 2.4.67
PHP Version: 8.5.6 (fpm-fcgi)
PHP Memory Limit: 640M
PHP Max Execution Time: 60
MySQL version: MariaDB 10.11.14
Zend Opcache: reported as disabled by configuration (shared hosting)

== WordPress Environment ==
Theme: Astra
Multisite: No
Debug Mode: Inactive

== Plugin Environment ==
Elementor 4.2.2 (free, no Elementor Pro)
All plugins up to date.
Other active plugins: Astra Starter Templates, SureRank SEO, WPForms Lite, WPCode Lite, WP Super Cache, WP Armour Honeypot, Google Site Kit, SeedProd, Yoast Duplicate Post, Regenerate Thumbnails, Easy HTTPS Redirection, plus the Elementor.com companion plugins (Manage, Web Accessibility, Email Deliverability, Image Optimization).

== Elementor Settings ==
Experiments enabled: container, nested-elements. All others left on default.
Disable Default Colors: checked
Disable Default Fonts: checked
CSS Print Method: External File
Load Google Fonts Locally: enabled
Lazy Load Background Images: disabled
Element Cache: 1 day (also tested with cache disabled - no change)

== What I already ruled out ==
- Full browser restart, freshly loaded editor: reproduces every time.
- Elementor element cache disabled: no change.
- The preview iframe does load correctly; `elementorFrontend` is defined in both the parent and the iframe once boot completes.
- Editor state looks healthy: `elementor.documents.getCurrent()` returns a document, its `container` exists, and `elementor.settings.page` is present.

== Other console errors at editor boot (possibly related) ==

ReferenceError: elementorFrontend is not defined
at editor.min.js?ver=4.2.2:2:520397

TypeError: Cannot read properties of null (reading 'parentElement')
at ToggleIcon.apply (checklist.min.js?ver=4.2.2:2:47938)
```

### Agreement

- [x] I confirm I have read and followed all the guidelines and instructions outlined in the Elementor Bug Report form.
- [x] I agree that my issue may be closed without further action if it doesn't meet all the requirements outlined in the Elementor Bug Report form.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.