Edit modal becomes unresponsive with nested paragraphs and large content sets due to overridden data-drupal-selector in Gin sticky actions

Created on 19 May 2025, 14 days ago

Problem/Motivation

  • When editing a paragraph item in a node form (using the Paragraphs module), the edit modal becomes unresponsive under certain conditions. The issue appears when:
    • The node contains a large number of paragraph items (approximately 60 or more).
    • The paragraph structure includes nested paragraphs.
    • After investigation, the problem was traced to a code change introduced in Issue #3489493, where the following line was added:

$button['#attributes']['data-drupal-selector'] = 'gin-sticky-' . $button['#attributes']['data-drupal-selector'];

This overrides Drupal’s core-generated data-drupal-selector, which is essential for JS behavior attachment particularly in modal and AJAX contexts.

Steps to reproduce

  1. Enable the Gin theme (version 8.x-3.0).
  2. Create a content type with a Paragraphs field that has nested (child) paragraphs.
  3. Create a node containing a paragraph item with approximately 60 nested (child) paragraph entries.
  4. Attempt to edit the paragraph item.
  5. Observe that the edit modal takes a long time to load or becomes unresponsive.

Root Cause

Overwriting data-drupal-selector breaks Drupal's behavior attachment system:

  • JavaScript behaviors tied to specific selectors fail to attach or reattach.
  • AJAX replacements don't match the modified selector, leading to misbehavior.
  • Components like CKEditor, media modals, and buttons may reinitialize infinitely or not at all.

Additional Notes

  • Removing the following line resolves the paragraph loading issue in my environment:
  • $button['#attributes']['data-drupal-selector'] = 'gin-sticky-' . $button['#attributes']['data-drupal-selector'];
  • However, further investigation is needed to understand the original purpose of this change. A proper fix should preserve the intended functionality while avoiding regressions or performance issues—especially in cases involving nested paragraphs and large content structures.
  • A patch or conditional implementation may be necessary to ensure compatibility across use cases.
🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India nivedha

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024