adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
723 stars 737 forks source link

Image caption default from DAM dialog option conflicting with Teaser dialog #2742

Open HitmanInWis opened 2 months ago

HitmanInWis commented 2 months ago

Bug Report

Bug as of: 2.24.7-SNAPSHOT

On the Teaser dialog, if you have an Asset selected that has a Title (Caption) from the DAM, clicking the checkbox for "Get title from linked page" on the Text tab will disable the Title field (correct) and set the value to the Asset Title (incorrect) rather than linked page title. This bug impacts only the dialog displaying the wrong value - when the Teaser is rendered on the page, the title is correctly used from the linked page, not the Asset.

The issue is in the Image editor clientlib: apps/core/wcm/components/image/v3/image/clientlibs/editor/js/image.js

Line 82:

            captionTuple = new CheckboxTextfieldTuple(dialogContent, 'coral-checkbox[name="./titleValueFromDAM"]', 'input[name="./jcr:title"]');

The selector of input[name="./jcr:title"] is too generic, and thus on the Teaser dialog it captures the teaser title field when creating the checkbox tuple, and thus seeds the input box with the Image title from the DAM.

A potential solution is to add granite:class="cmp-image__editor--caption" to the image dialog field for Caption, and then update the JS code to:

            captionTuple = new CheckboxTextfieldTuple(dialogContent, 'coral-checkbox[name="./titleValueFromDAM"]', 'input.cmp-image__editor--caption');