-
Notifications
You must be signed in to change notification settings - Fork 482
[BUG] SyntaxError: Identifier 'SOURCE_FIELD' has already been declared in Edit Content Beta Native Custom Field #35215
Description
Problem Statement
Muskegon reports that Edit Content Beta crashes when interacting with certain custom fields in the native custom field renderer.
When the custom field re-renders (for example, after navigating away and back to the same content form), the UI fails with a runtime error and the custom field area becomes unusable.
Reported by: Miller Gonzalez
Customer: Muskegon
Browser & OS: Not provided in the report (customer recording available in Slack)
Console error:
Uncaught SyntaxError: Failed to execute 'insertBefore' on 'Node': Identifier 'SOURCE_FIELD' has already been declared
at Cc.insertBefore (chunk-IOFCBIL5.js:6:170849)
at Gi.insertBefore (main-LOB657K7.js:1:75022)
at Bl (chunk-IOFCBIL5.js:6:7800)
at ls (chunk-IOFCBIL5.js:6:22843)
at rv (chunk-IOFCBIL5.js:6:26090)
at gd (chunk-IOFCBIL5.js:6:26164)
at BL (chunk-IOFCBIL5.js:6:26611)
at ls (chunk-IOFCBIL5.js:6:23029)
at rv (chunk-IOFCBIL5.js:6:26090)
at VS (chunk-IOFCBIL5.js:6:26479)
Likely root cause is repeated dynamic script injection in mountComponent() inside native-field.component.ts, where custom-field script code is executed again on re-render and redeclares let/const identifiers in global scope (for example SOURCE_FIELD).
Steps to Reproduce
Video screencast: Available in the linked Slack thread.
- Open Edit Content Beta.
- Open a contentlet containing a Custom Field whose script declares
SOURCE_FIELD(or similarconst/letglobals). - Navigate away from the contentlet and return (or otherwise trigger form/component re-render).
- Observe the console error and broken custom-field UI.
Acceptance Criteria
- Re-rendering the same custom field in Edit Content Beta does not throw
Identifier 'SOURCE_FIELD' has already been declaredor equivalent redeclaration errors. - The native custom field renderer isolates or cleans up dynamically injected scripts so script variables do not collide across mounts.
- On component teardown, previously injected runtime artifacts (script nodes/listeners/resources owned by the renderer) are cleaned up to prevent duplicate execution on remount.
- A regression check covers at least one navigation/remount flow to ensure custom fields continue to function after reopening the same form.
dotCMS Version
Edit Content Beta (customer-reported environment, report date: 2026-04-01). Exact dotCMS version/build not included in the report.
Severity
High - Major functionality broken
Links
- Freshdesk ticket: NA
- Slack thread: https://dotcms.slack.com/archives/C0893BF7GRJ/p1775070512781729
- Affected component path:
core-web/libs/edit-content/src/lib/fields/dot-edit-content-custom-field/components/native-field/native-field.component.ts
Metadata
Metadata
Assignees
Labels
Type
Projects
Status