Skip to content

Add secondary CTA support to productDetail product cards - #171

Merged
BNanda99 merged 2 commits into
adobe:devfrom
BNanda99:feature/product-card-secondary-cta
Sep 28, 2026
Merged

BNanda99 merged 2 commits into
adobe:devfrom
BNanda99:feature/product-card-secondary-cta

Conversation

@BNanda99

Copy link
Copy Markdown
Member

Description

Adds secondary CTA support to the productDetail product card style (ExtendedProductCard). Product cards can now render both a primary (filled) and secondary (outlined) call-to-action side by side, sourced from entity_info.primary / entity_info.secondary.

  • Introduces an ordered, validated ProductDetailCta list (productDetailCtas()) as the single source of truth for which CTAs render, in what order (primary before secondary), and with what (trimmed) text/url. An action is included only when both its text and url are non-blank after trimming.
  • Renders primary as the existing filled pill; secondary as a new outlined style with its own background/text/border colors and border width.
  • A lone CTA keeps its intrinsic width (no full-width regression); 2+ CTAs share the row equally, separated by a dedicated 8dp gap independent of the buttons' own padding.
  • Adds 4 new theme CSS variables, reusing the primary CTA's radius/padding/font tokens by design:
    • --product-card-secondary-cta-button-background-color
    • --product-card-secondary-cta-button-text-color
    • --product-card-secondary-cta-button-border-color
    • --product-card-secondary-cta-button-border-width
  • Also fixes a pre-existing bug: the CTA row was previously hidden entirely whenever a subtitle (entity_info.productDescription) was present, on the assumption there wasn't room for both at the card's fixed height. Real backend responses populate a subtitle on every card, which silently hid all CTAs. CTA visibility now depends only on having a valid action. The card's content already scrolls internally past its max height, so this doesn't introduce clipping.

The actionButton card style (ProductCard/ProductActionButtons) already supported both CTAs before this change and was intentionally left untouched.

Related Issue

Motivation and Context

Product cards were limited to a single CTA, but the backend can supply both a primary action (e.g. "Buy now") and a secondary action (e.g. "Learn more" / "Get directions").

How Has This Been Tested?

  • Full unit test suite: 1559/1559 passing (./gradlew :concierge:testPhoneDebugUnitTest), including new coverage for:
    • ExtendedProductCardLogicTest — the productDetailCtas() builder: primary-only, both-valid (ordering), secondary-only when primary invalid, dropped when text/url null/blank/whitespace, trimming, empty list.
    • CSSKeyMapperTest — the 4 new CSS variable mappings, malformed-value fallback, key coverage.
  • Instrumented (androidTest) UI tests added/updated in ExtendedProductCardTest covering: both CTAs render in order, secondary-only when primary is invalid, secondary dropped on blank url, whitespace trimming on tap, click isolation (secondary tap doesn't fire card click), no-full-width regression for a lone CTA, equal width-sharing for two CTAs, and CTA visibility with a subtitle present (regression test for the bug fix above). These compile clean but could not be run on-device in this environment (no emulator/adb available) — recommend running on a device before merging.
  • Manual verification via the debug ProductCardDemoScreen, updated with primary-only, primary+secondary, dropped-secondary (blank url), subtitle+both-CTAs, and no-CTA sample cards.

Screenshots (if appropriate):

image image

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.

Mirrors the iOS implementation: entity_info.secondary renders as an
outlined CTA next to the existing filled primary CTA, via a shared
validated/ordered CTA-list builder. A lone CTA keeps its intrinsic
width; two or more share the row equally. Adds the 4 matching
--product-card-secondary-cta-button-* theme tokens end to end
(models, layout, colors, CSS mapper, styles) plus style-guide docs,
demo seed data, and unit/instrumented test coverage.

Also removes a pre-existing rule that hid the whole CTA row whenever
a subtitle (entity_info.productDescription) was present -- real
backends populate that field on every card, which silently hid CTAs
entirely. Visibility now depends only on a valid action (text + url),
matching iOS.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

CI's instrumented tests caught a real regression: the secondary CTA
button's inner Box had fillMaxWidth(), which greedily claims the full
incoming width constraint regardless of the outer wrapContentWidth()
modifier meant to keep a lone CTA at its intrinsic size. weight(1f)
already forces an exact width for the 2-CTA case, so the fillMaxWidth
was unnecessary there and actively wrong for the 1-CTA case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@BNanda99
BNanda99 marked this pull request as ready for review September 20, 2026 07:47
@navratan-soni

Copy link
Copy Markdown
Contributor

Can you add product requirement JIRA for this.

@BNanda99

Copy link
Copy Markdown
Member Author

Can you add product requirement JIRA for this.

https://jira.corp.adobe.com/browse/BRANDCON-9458

@rymorale rymorale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@BNanda99
BNanda99 merged commit 06d6c4c into adobe:dev Sep 28, 2026
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.

4 participants