Skip to content

fix: make CardBody slot full width in selectable card component - #3898

Open
rzp-slash[bot] wants to merge 2 commits into
masterfrom
fix/selectable-card-slot-full-width
Open

fix: make CardBody slot full width in selectable card component#3898
rzp-slash[bot] wants to merge 2 commits into
masterfrom
fix/selectable-card-slot-full-width

Conversation

@rzp-slash

@rzp-slash rzp-slash Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Problem

The CardBody slot in the selectable card component does not occupy the full width, causing a layout discrepancy with the provided designs. The slot was missing an explicit width prop, and in certain flex contexts (e.g. when nested inside RadioGroup/CheckboxGroup wrappers) it would shrink to content width instead of filling the card.

Solution

Added width="100%" to the BaseBox rendered by CardBody in packages/blade/src/components/Card/Card.tsx, ensuring the body slot always stretches to the full card width regardless of parent flex context.

Changes

  • packages/blade/src/components/Card/Card.tsx — added width="100%" to CardBody's BaseBox
  • Updated snapshots in Card.web.test.tsx, Card.ssr.test.tsx, and CardInteractive.web.test.tsx

Verification

  • yarn typecheck — passes
  • yarn test:react Card — all 30 tests pass, 20 snapshots pass

Reference

Slack thread discussion with @rastogi_saurav about selectable card slot not occupying full width.

The CardBody slot did not have an explicit width, causing it to not occupy the full card width in certain flex contexts (e.g. when nested inside RadioGroup/CheckboxGroup wrappers). This resulted in a layout discrepancy with the provided designs for selectable cards.

Added width="100%" to the BaseBox in CardBody to ensure the slot always fills the card width.

Co-authored-by: rsubhojitdesign <subhojit.roy@razorpay.com>
@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 35d99f8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the blade Changes to packages/blade label Aug 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Slash AI Review has been triggered. View execution logs

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🤖 Slash PR Healer has been triggered. View execution logs

(Review Cancelled - Superseded by a new run)

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Slash AI Review has been triggered. View execution logs

@kamaleshs-bridge4 kamaleshs-bridge4 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.

✨ Agentic PR Review ✨

UI Review

✅ 4 passed

Passing checks (4)
Check Screenshot
Card Interactive - Single Selectable Card with Radio
Card Interactive - Multi Selectable Card with Checkbox
Card - Card Body Content
Card - Default Example

<BaseBox
{...metaAttribute({ name: MetaConstants.CardBody, testID })}
{...makeAnalyticsAttribute(rest)}
width="100%"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 [MAJOR] · code-quality-critique · confidence: 9/10

Problem: Native test snapshots not updated — adding width="100%" changes CardBody's rendered style on React Native from {} to {"width":"100%"}, but Card.native.test.tsx.snap and CardInteractive.native.test.tsx.snap were not updated. CI runs yarn test which includes test:react-native, so native tests will fail with snapshot mismatches.

Suggestion: Update the native snapshots by running yarn test:react-native Card with --updateSnapshot (or -u).

<BaseBox
{...metaAttribute({ name: MetaConstants.CardBody, testID })}
{...makeAnalyticsAttribute(rest)}
width="100%"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 [MINOR] · code-quality-critique · confidence: 8/10

Problem: Missing changeset — this is a user-facing bug fix that changes CardBody's layout behavior, but no changeset file was added to .changeset/.

Suggestion: Add a changeset file (e.g., .changeset/card-body-full-width.md) with a patch bump for @razorpay/blade describing the CardBody width fix.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Slash PR Healer failed to trigger. View workflow run

@rzp-slash rzp-slash Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✨ Agentic PR Review ✨

Status: Approved ✅

UI Review

✅ 12 passed

Passing checks (12)
Check Screenshot
Card default (card-example) story
Card body content story
Card without padding story
Single selectable card with radio (RadioGroup context)
Multi selectable card with checkbox (CheckboxGroup context)
Selectable card with label left
Secondary card story
Nested secondary inside primary story
Clickable card story
Hoverable card story
Master storybook comparison (selectable card with radio)
Radio selection interaction

Usage

import { Card, CardBody } from '@razorpay/blade/components';

<Card>
  <CardBody>Content</CardBody>
</Card>

@rzp-slash rzp-slash Bot added the rcore:eligible-for-auto-approval PR is approved by slash label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blade Changes to packages/blade rcore:eligible-for-auto-approval PR is approved by slash react-native

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants