Skip to content

Fix repeatable WYSIWYG fields infinite loop after import (Issue #7465)#7487

Merged
sc0ttkclark merged 1 commit intopods-framework:mainfrom
faisalahammad:fix/issue-7465-repeatable-wysiwyg-fields
Feb 22, 2026
Merged

Fix repeatable WYSIWYG fields infinite loop after import (Issue #7465)#7487
sc0ttkclark merged 1 commit intopods-framework:mainfrom
faisalahammad:fix/issue-7465-repeatable-wysiwyg-fields

Conversation

@faisalahammad
Copy link
Contributor

@faisalahammad faisalahammad commented Jan 31, 2026

Summary

Fixes #7465 - Repeatable WYSIWYG fields become uneditable after WordPress content import, causing React error #185 ("Maximum update depth exceeded").

Problem Analysis

🔴 The Bug

When editing a post with repeatable WYSIWYG fields (using Quill editor) that were imported via WordPress XML Import, the fields become completely uneditable and the browser console shows:

Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185

This error means "Maximum update depth exceeded" - an infinite re-render loop in React.

🔍 Root Cause

The issue is in ui/js/dfv/src/fields/wysiwyg/index.js where ReactQuill's onChange handler directly calls setValue:

// ❌ BEFORE - Causes infinite loop
<ReactQuill
  value={ value || '' }
  onChange={ setValue }  // Problem here!
  ...
/>

Why this causes an infinite loop:

  1. ReactQuill mounts with imported HTML content → fires onChange(content, delta, source)
  2. setValue(content) is called → updates React state
  3. Component re-renders with the "new" value (same content, but React sees it as changed)
  4. ReactQuill detects value prop change → fires onChange again
  5. Loop continues indefinitely → React Error get_* for Pods item for meta-based types #185

The source parameter in ReactQuill's onChange tells us why the change happened:

  • 'user' = User typed/edited content
  • 'api' = Programmatic change (like setting initial value)
  • 'silent' = Internal change that shouldn't trigger events

✅ The Fix

Only call setValue when the change was initiated by the user:

// ✅ AFTER - No infinite loop
<ReactQuill
  value={ value || '' }
  onChange={ ( content, delta, source ) => {
    // Only update state for user-initiated changes
    // to prevent infinite loops on mount/programmatic updates
    if ( source === 'user' ) {
      setValue( content );
    }
  } }
  ...
/>

This is the recommended approach from react-quill documentation.

Code Changes

Before/After Diff

 <ReactQuill
   value={ value || '' }
   onBlur={ () => setHasBlurred() }
-  onChange={ setValue }
+  onChange={ ( content, delta, source ) => {
+    // Only update state for user-initiated changes
+    // to prevent infinite loops on mount/programmatic updates
+    if ( source === 'user' ) {
+      setValue( content );
+    }
+  } }
   theme="snow"
   modules={ { toolbar: QUILL_TOOLBAR_OPTIONS } }
   readOnly={ toBool( readOnly ) }
 />

Files Changed

File Change
ui/js/dfv/src/fields/wysiwyg/index.js Fixed onChange handler to check source parameter

Testing

Automated Tests

  • ✅ All 42 Jest tests pass
  • ✅ Production build compiles successfully

Manual Testing

  • ✅ Imported the reporter's Pod configuration and WordPress XML export
  • ✅ Verified repeatable WYSIWYG fields are now editable
  • ✅ No React errors in browser console
  • ✅ Content saves and persists correctly

How to Test

  1. Install this patched plugin zip
  2. Import the Pod configuration from the issue
  3. Import the WordPress XML export from the issue
  4. Edit the imported "tuote" post type items
  5. Verify WYSIWYG fields are editable with no console errors

Screenshots

Before:
image

After:
25B26829-6AF3-4ACD-BB01-BA20AD82630A

Related

The ReactQuill onChange handler was directly calling setValue, which caused
an infinite render loop when:
1. ReactQuill fires onChange on mount/value changes
2. setValue updates React state
3. State update triggers re-render
4. ReactQuill sees 'new' value and fires onChange again

Fixed by checking the source parameter - only call setValue when source
is 'user' to prevent infinite loops on mount/programmatic updates.

This follows the recommended approach from react-quill documentation.
@what-the-diff
Copy link

what-the-diff bot commented Jan 31, 2026

PR Summary

  • Improvement in User Interaction Handling
    The change improved how the ReactQuill component responds to interactions from the user by updating the state only when user-based changes are made. This prevents endless loops that can occur during initialization or automatic updates, leading to increased efficiency and improved user experience.

@sc0ttkclark sc0ttkclark added this to the Pods 3.3.5 milestone Feb 22, 2026
@sc0ttkclark sc0ttkclark changed the base branch from main to release/3.3.5 February 22, 2026 04:11
@sc0ttkclark sc0ttkclark changed the base branch from release/3.3.5 to main February 22, 2026 04:14
@sc0ttkclark sc0ttkclark merged commit 2539b80 into pods-framework:main Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pods custom fields not editable when editing a custom post with repeatable WYSIWYG fields

2 participants