From 5b734956bb949e41d1aea818a3afb5ec66c08dc7 Mon Sep 17 00:00:00 2001 From: edleeks87 Date: Thu, 23 May 2024 11:59:37 +0100 Subject: [PATCH] fix(card): ensure that focus outline wraps all card content when `height` prop is set Ensures that the card content has a responsive height so the focus styles wrap all of the interactive area of the content when the `Card` has a `height` prop passed fix #6741 --- src/components/card/card-test.stories.tsx | 77 +++++++++++++++++++++- src/components/card/card.pw.tsx | 4 +- src/components/card/card.style.ts | 4 ++ src/components/card/components.test-pw.tsx | 4 +- 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/src/components/card/card-test.stories.tsx b/src/components/card/card-test.stories.tsx index 3553f4f2ba..d39a3e1da8 100644 --- a/src/components/card/card-test.stories.tsx +++ b/src/components/card/card-test.stories.tsx @@ -12,7 +12,7 @@ import Box from "../box"; export default { title: "Card/Test", - includeStories: ["DefaultStory"], + includeStories: ["DefaultStory", "CustomHeight"], component: Card, parameters: { docs: { @@ -277,3 +277,78 @@ export const CardTextAlignment = ({ ...props }) => { ); }; + +export const CustomHeight = () => { + return ( + <> + {}} + footer={ + + + + Footer link + + + + } + > + + + + + Additional text + + + + + + + + + + Body text + + + Even more text + + + + + + + Footer link + + + + } + > + + + + + Additional text + + + + + + + + + + Body text + + + Even more text + + + + + ); +}; diff --git a/src/components/card/card.pw.tsx b/src/components/card/card.pw.tsx index fc7fa99722..91528271ab 100644 --- a/src/components/card/card.pw.tsx +++ b/src/components/card/card.pw.tsx @@ -60,7 +60,7 @@ test.describe("Check Card component styling", () => { mount, page, }) => { - await mount(); + await mount(); const cardElement = card(page); const cardContentElement = cardContent(page); @@ -78,6 +78,8 @@ test.describe("Check Card component styling", () => { "box-shadow", "rgb(255, 188, 25) 0px 0px 0px 3px, rgba(0, 0, 0, 0.9) 0px 0px 0px 6px" ); + + await expect(cardContentElement).toHaveCSS("height", "500px"); }); test(`should match the expected styling when ${key} is passed with custom boxShadow and hoverBoxShadow props`, async ({ diff --git a/src/components/card/card.style.ts b/src/components/card/card.style.ts index fc42d41199..1ba90111eb 100644 --- a/src/components/card/card.style.ts +++ b/src/components/card/card.style.ts @@ -109,6 +109,9 @@ const StyledCardContent = styled.div.attrs( interactive && css` cursor: pointer; + display: inline-flex; + flex-direction: column; + height: 100%; ${!theme.focusRedesignOptOut && css` @@ -119,6 +122,7 @@ const StyledCardContent = styled.div.attrs( `} `} + align-items: stretch; outline: none; text-decoration: none; background-color: inherit; diff --git a/src/components/card/components.test-pw.tsx b/src/components/card/components.test-pw.tsx index c396de186a..2fb98b8706 100644 --- a/src/components/card/components.test-pw.tsx +++ b/src/components/card/components.test-pw.tsx @@ -334,8 +334,8 @@ export const WithWidthProvided = () => ( ); -export const WithCustomHeight = () => ( - +export const WithCustomHeight = (props: Partial) => ( +