Breaks layout paragraphs editing functions

Created on 28 November 2023, about 1 year ago
Updated 11 September 2024, 3 months ago

Problem/Motivation

When this module is installed alongside Layout Paragraphs, the editing controls of layout paragraphs do not render because this module changes the id in the code

function ptoc_preprocess_paragraph(&$variables) {
  if ('default' == $variables['elements']['#view_mode']) {
    $variables['attributes']['id'] = 'paragraph-' . $variables['paragraph']->id();
  }...
}

Steps to reproduce

Install both modules and create a content type which uses layout paragraphs on a field. When editing the the controls will not render.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom ded

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India santhosh@21

    The same issue I got when using Layout Paragraphs and Paragraphs module as the preprocess paragraph is changing the default id values to "pargraph-id" and it is affecting the Layout Paragraphs and losing the editing controls of layout paragraphs.

    The below code fixed the issue for Layout editing

    Also Attached the patch for someone who is looking for

    function ptoc_preprocess_paragraph(&$variables) {
      // Check if the ID attribute is already set.
      if (!isset($variables['attributes']['id'])) {
        // Generate a new ID only for paragraphs in the default view mode.
        if ('default' == $variables['elements']['#view_mode']) {
          $variables['attributes']['id'] = 'paragraph-' . $variables['paragraph']->id();
        }
      }
     
      if (Drupal::config('ptoc.settings')->get('debug')) {
        $variables['attributes']['class'][] = 'ptoc-debug';
        $variables['#attached']['library'][] = 'ptoc/ptoc-debug';
      }
    }
    
    
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review 7 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to RTBC 3 months ago
  • 🇮🇳India rifas-ali-pbi Kerala

    I have tested this patch. After applying this patch now Paragraph is working fine.

Production build 0.71.5 2024