Skip to content

190: Render the gallery modal from the paragraph entity instead of by ID - Alternative - #496

Open
dblanken-yale wants to merge 2 commits into
developfrom
190-add-block-cloning
Open

190: Render the gallery modal from the paragraph entity instead of by ID - Alternative#496
dblanken-yale wants to merge 2 commits into
developfrom
190-add-block-cloning

Conversation

@dblanken-yale

@dblanken-yale dblanken-yale commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

190: Add Block Cloning Functionality

Description of work

  • templates/paragraphs/_gallery-item.twig rendered the lightbox contents with
    drupal_entity('paragraph', item.entity.id.0.value, ...), which needs a saved
    paragraph ID. An unsaved paragraph has none, so the modal came out empty in the Layout
    Builder preview even though the media reference was present and the canonical node route
    was fine.
  • Now renders from the entity object via twig_tweak's view filter, which takes an
    EntityInterface and keeps the same check_access default — no access change.
  • This affected any unsaved gallery item, not only cloned ones: adding a gallery item and
    previewing before save hit the same empty modal. The old is not iterable guard was
    suppressing the error rather than fixing the cause.
  • Single work unit with the companion yalesites-project PR — that PR adds the Clone
    option that makes this reachable, and it carries the matching branch name that
    build_frontend needs to swap this branch into the multidev.
  • Other work completed in: 190: Add block cloning to Layout Builder - Alternative yalesites-project#1414

Functional testing steps:

  • On a page with a Gallery block, open the block in Layout Builder and confirm the grid thumbnails still look identical to before
  • Click a thumbnail and confirm the lightbox opens with the full image and its caption/heading
  • Add a new gallery item and, before saving, open its lightbox from the Layout Builder preview — the image should now appear (previously blank)
  • Clone a Gallery block (companion PR) and confirm the copy's lightbox shows the right images in the preview
  • View the page on the canonical route (not Layout Builder) and confirm the gallery and lightbox are unchanged

References yalesites-org/YaleSites-Internal#190


Created with AI

The modal rendered via drupal_entity('paragraph', id, ...), which needs a
saved paragraph ID. A newly added gallery item, or one belonging to a block
just cloned in Layout Builder, has no ID yet, so the lightbox came out empty
in the Layout Builder preview even though the media reference was present.
Render from the entity object with twig_tweak's `view` filter instead, which
takes an EntityInterface and keeps the same check_access default.

Refs yalesites-org/YaleSites-Internal#190

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts:
#	templates/paragraphs/_gallery-item.twig
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.

1 participant