Problem/Motivation

I'm using the Paragraph component in Canvas Bootstrap. When I clear the placeholder text, I get the following error message:

Twig\Error\RuntimeError occurred during rendering of component 41981e00-0dfa-44bb-b3cb-b8c6e5648955 in Page Untitled page (37), field components: An exception has been thrown during the rendering of a template (""value" is an invalid render array key. Value should be an array but got a string.") in "canvas_bootstrap:paragraph" at line 20.

Steps to reproduce

Drag Paragraph component into a Canvas page. Delete the placeholder text. The message will appear in the preview pane.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sduong created an issue. See original summary.

vinodhini.e made their first commit to this issue’s fork.

bala.addweb changed the visibility of the branch 3641386-paragraph-component-throws to hidden.

bala.addweb changed the visibility of the branch 3641386-paragraph-component-throws to active.

bala.addweb’s picture

Opened an MR against 1.0.x that fixes the Twig RuntimeError shown when the Paragraph component's text is cleared.

Cause

When the text is cleared, Canvas passes text as an array with a plain value key. The template sees that text is iterable and runs it through |render. Drupal then treats the array as a render array and fails with: "value" is an invalid render array key. Value should be an array but got a string.

Fix

In components/paragraph/paragraph.twig, if text is iterable and has a non-iterable value, the template now uses that value directly. Real render arrays still go through |render, and plain strings work as before.

Testing steps

  1. Add the Paragraph component to a Canvas page.
  2. Delete the placeholder text.
    • Before: the preview pane shows the Twig RuntimeError.
    • After: the component renders empty, with no error.
  3. Type text with HTML formatting, such as bold or a list, and confirm it still renders correctly.
bala.addweb’s picture

Status: Active » Needs review

  • bala.addweb committed 48772651 on 1.0.x
    #3641386: Paragraph component throws error message when text is cleared.
    
alaa abbad’s picture

Status: Needs review » Fixed

Thanks @bala.addweb, reviewed and merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.