Skip to content

[MAR-2887] Add support for taller product card descriptions - #179

Merged
rymorale merged 5 commits into
adobe:devfrom
rymorale:mar-2887-taller-product-card-support
Sep 29, 2026
Merged

rymorale merged 5 commits into
adobe:devfrom
rymorale:mar-2887-taller-product-card-support

Conversation

@rymorale

Copy link
Copy Markdown
Contributor

Support taller product card descriptions

Description

Add the --product-card-description-max-lines theme option for extended product cards. It defaults to two lines; positive values set the limit, while none, zero, negative, or invalid values leave descriptions unclamped. Increase the card’s maximum height as needed to display longer descriptions.

When an extended-card carousel contains a CTA, reserve an invisible CTA slot on cards without one to keep prices aligned. Update the demo with 2-, 4-, and 6-line descriptions and a longer description that demonstrates ellipsis.

Related Issue

MAR-2887

Motivation and Context

Product descriptions were limited to two lines, preventing taller product cards from showing more copy. This change supports longer descriptions through theme configuration and keeps price and CTA areas aligned across carousel cards.

How Has This Been Tested?

  • The focused CSSKeyMapperTest unit tests passed.
  • Android-test Kotlin compilation passed.
  • Added UI coverage for description truncation and CTA-slot alignment through ProductCarousel.
  • Lint reports existing API-level errors in AppLinkUtils.kt and ConciergeConversationServiceClient.kt.

Screenshots (if appropriate):

Screen_recording_20260929_120954.webm

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Add configurable description limits to extended product cards. The new `--product-card-description-max-lines` option defaults to two lines and supports unclamped descriptions with `none` or invalid values. Carousels reserve CTA space across cards to keep prices aligned.
- Update the product card demo with 2-, 4-, and 6-line descriptions and a longer sample to demonstrate ellipsis.
- Add config and UI tests, and document the theme option.
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

@rymorale
rymorale requested a review from cdhoffmann September 29, 2026 19:21
Add tests for:
- product-card-description-max-lines keeping existing layout values
- descriptionMaxLines defaulting to 2 and being set by the theme
- the reserved CTA placeholder being hidden from accessibility and not
  tappable
- the reserved CTA placeholder still taking up space on the card

Fix productCarousel_reservesCtaSlotAcrossExtendedCards, which failed
because the carousel's hidden sizing copy of each card also matched the
price text. The test now reads only the visible card.

@cdhoffmann cdhoffmann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - threading reserveCtaSlot into the measureItem pass as well as the render pass is the easy thing to miss here, and the placeholder is properly inert.

Three things inline. The line-clamp semantics one is on us: we shipped the same behavior you have here and then changed it after you'd already written this, so apologies for the moving target.

subtitleFontWeight = subtitleWeight,
subtitleLineHeight = (subtitleSize.value * smallTextLineHeightFactor).sp,
subtitleLetterSpacing = (-0.5).sp,
descriptionMaxLines = layout?.productCardDescriptionMaxLines ?: 2,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConciergeLayout is public, so a host app can construct it directly and bypass the takeIf { it > 0 } guard in CSSKeyMapper:

ConciergeLayout(productCardDescriptionMaxLines = 0)

Compose's TextDelegate does require(maxLines > 0), so that throws at render time. Worth coercing at the point of use since that's the only place guaranteed to see every value:

descriptionMaxLines = (layout?.productCardDescriptionMaxLines ?: 2).coerceAtLeast(1),

},
"product-card-description-max-lines" to { cssValue, theme ->
updateLayout(theme) { layout ->
val maxLines = cssValue.trim().toIntOrNull()?.takeIf { it > 0 } ?: Int.MAX_VALUE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we align this with iOS and have invalid values leave the token unset rather than unbounded?

This is our fault for moving late - we originally shipped exactly what you have here, then changed it in adobe/aepsdk-concierge-ios#168 after you'd written this. The reason we switched: every other token treats an unparseable value as "unset" and falls back to the component default, and this was the only one where junk input produced a visibly different layout instead. The empty-string case is the one that pushed it over for us, since "--product-card-description-max-lines": "" silently unclamping reads more like a typo than an intent.

Concretely that'd mean dropping ?: Int.MAX_VALUE so none, 0, negatives, and unparseable values all fall through to the default of 2.

Happy to go the other way and change iOS back instead if you prefer the CSS -webkit-line-clamp reading - mainly want the two to match.

val itemWidth = if (useExtendedProductCards) extendedProductCardStyle.cardWidth else style.imageWidth
val carouselMode = ConciergeTheme.behavior?.multimodalCarousel?.carouselStyle ?: CarouselStyle.PAGED
val isPaged = carouselMode == CarouselStyle.PAGED
val reserveCtaSlot = useExtendedProductCards && elements.any { productDetailCtas(it).isNotEmpty() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this re-runs productDetailCtas for every element on each recomposition, while the same call inside the card is remember(element)-wrapped. remember(elements) would match.

- Align `--product-card-description-max-lines` parsing with iOS by ignoring invalid values, clamp directly configured nonpositive line counts to prevent Compose failures, and memoize carousel CTA-slot detection.
- Update the style guide and add regression coverage for mapper behavior and invalid direct theme values.

@cdhoffmann cdhoffmann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three addressed - thanks for turning that around fast, and sorry again for the late semantics change on our side.

Returning the theme untouched on an unparseable value is better than what I suggested: it means an invalid value can't clobber an already-set one, and the test for that is a nice catch. Ours overwrites with nil in that case, though JSON key uniqueness makes it unreachable in practice.

Two nits below, neither blocking.

Also worth noting for the record: promptMaxLines: Int = Int.MAX_VALUE in the same file means your original reading had precedent here - appreciate you aligning to us anyway.

val productCardTitleFontSize: Double? = null,
val productCardSubtitleFontWeight: Int? = null,
val productCardSubtitleFontSize: Double? = null,
/** Maximum description lines; [Int.MAX_VALUE] represents an unbounded description. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this now points at a capability the token no longer has - the CSS path can't produce Int.MAX_VALUE anymore, so the doc reads as though unbounded is still reachable through a theme.

subtitleFontWeight = subtitleWeight,
subtitleLineHeight = (subtitleSize.value * smallTextLineHeightFactor).sp,
subtitleLetterSpacing = (-0.5).sp,
descriptionMaxLines = (layout?.productCardDescriptionMaxLines ?: 2).coerceAtLeast(1),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 0 now means two different things depending on how it arrives - CSS "0" is ignored and falls back to two lines, while ConciergeLayout(productCardDescriptionMaxLines = 0) coerces to one. .takeIf { it > 0 } ?: 2 would land both on the same default. The crash is fixed either way, and the new test passes under both.

@rymorale
rymorale merged commit fa70595 into adobe:dev Sep 29, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants