Repository navigation
[MAR-2887] Add support for taller product card descriptions - #179
Conversation
- 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 Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
left a comment
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() } |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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. */ |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
Support taller product card descriptions
Description
Add the
--product-card-description-max-linestheme option for extended product cards. It defaults to two lines; positive values set the limit, whilenone, 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?
CSSKeyMapperTestunit tests passed.ProductCarousel.AppLinkUtils.ktandConciergeConversationServiceClient.kt.Screenshots (if appropriate):
Screen_recording_20260929_120954.webm
Types of changes
Checklist: