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
747 stars 753 forks source link

Container model json omits component properties, includes unnecessary authoring content #2772

Open HitmanInWis opened 5 months ago

HitmanInWis commented 5 months ago

Bug present as of version: 2.24.7-SNAPSHOT

At least it seems like a bug to me. The model JSON for a container component omits things like the container ID, the container layout type, and the background style - i.e. fields on com.adobe.cq.wcm.core.components.internal.models.v1.LayoutContainerImpl. The model JSON includes a list of allowedComponents which really shouldnt need to be exported (more of an authoring need).

I believe this is due to the model.json being the AEM default for a responsivegrid component (which container extends). This can be resolved by adding the following to LayoutContainerImpl

@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
HitmanInWis commented 5 months ago

The above "fix" only changes for the top-level container. For child containers to also display the container ID, layout type, and data layer in the model export, the adapters for LayoutContainerImpl must be updated as well.

        adapters = {LayoutContainer.class, ComponentExporter.class, ContainerExporter.class}, // Add latter 2