boltdesignsystem / bolt

The Bolt Design System provides robust Twig and Web Component-powered UI components, reusable visual styles, and powerful tooling to help developers, designers, and content authors build, maintain, and scale best of class digital experiences.
https://boltdesignsystem.com
MIT License
291 stars 46 forks source link

Update card media deprecation to check both src and attributes.src #2585

Closed remydenton closed 1 year ago

remydenton commented 1 year ago

Jira

https://pegadigitalit.atlassian.net/browse/DS-903

Summary

Fixes deprecation logic for image in cards

Details

https://github.com/boltdesignsystem/bolt/pull/2520 introduced a check for usage of the deprecated image component.

The check didn't take into account the possibility that a src prop could be passed either directly or as attributes.src. In the later case, the logic incorrectly assumed that a render array was being passed rather than structured data.

Ultimately, this should be fixed on the Drupal side, but this update fixes the break.

How to test

On a local Drupal site, find a page that has cards with images and is exhibiting the above error after updating to Bolt 5.8.0. Manually copy the change in this PR to the docroot/bolt/twig/packages/components/bolt-card-replacement/src/card-replacement-media/_card-replacement-media.twig. Clear caches, reload the page, and confirm errors are gone and card images display as expected.