From ac0d67181139946e44d667c72163aec8814d5ceb Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Thu, 21 Nov 2024 14:48:18 +0100 Subject: [PATCH] fix(SW-957 SW-958): Make selected EnterDetailsCards clickable --- .../EnterDetails/BedType/index.tsx | 3 +++ .../EnterDetails/Breakfast/index.tsx | 6 ++++++ .../TempDesignSystem/Form/ChoiceCard/_Card/card.ts | 1 + .../Form/ChoiceCard/_Card/index.tsx | 14 +++++++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/components/HotelReservation/EnterDetails/BedType/index.tsx b/components/HotelReservation/EnterDetails/BedType/index.tsx index eeb8237a0..a7290e40b 100644 --- a/components/HotelReservation/EnterDetails/BedType/index.tsx +++ b/components/HotelReservation/EnterDetails/BedType/index.tsx @@ -76,6 +76,9 @@ export default function BedType({ bedTypes }: BedTypeProps) { subtitle={width} title={roomType.description} value={roomType.value} + handleSelectedOnClick={ + bedType === roomType.value ? completeStep : undefined + } /> ) })} diff --git a/components/HotelReservation/EnterDetails/Breakfast/index.tsx b/components/HotelReservation/EnterDetails/Breakfast/index.tsx index fdaec3a84..a3be32d65 100644 --- a/components/HotelReservation/EnterDetails/Breakfast/index.tsx +++ b/components/HotelReservation/EnterDetails/Breakfast/index.tsx @@ -97,6 +97,9 @@ export default function Breakfast({ packages }: BreakfastProps) { })} title={intl.formatMessage({ id: "Breakfast buffet" })} value={pkg.code} + handleSelectedOnClick={ + breakfast === pkg.code ? completeStep : undefined + } /> ))} diff --git a/components/TempDesignSystem/Form/ChoiceCard/_Card/card.ts b/components/TempDesignSystem/Form/ChoiceCard/_Card/card.ts index 7d24e46d7..c733dac50 100644 --- a/components/TempDesignSystem/Form/ChoiceCard/_Card/card.ts +++ b/components/TempDesignSystem/Form/ChoiceCard/_Card/card.ts @@ -12,6 +12,7 @@ interface BaseCardProps title: React.ReactNode type: "checkbox" | "radio" value?: string + handleSelectedOnClick?: () => void } interface ListCardProps extends BaseCardProps { diff --git a/components/TempDesignSystem/Form/ChoiceCard/_Card/index.tsx b/components/TempDesignSystem/Form/ChoiceCard/_Card/index.tsx index 7d6ef8105..29ce8e531 100644 --- a/components/TempDesignSystem/Form/ChoiceCard/_Card/index.tsx +++ b/components/TempDesignSystem/Form/ChoiceCard/_Card/index.tsx @@ -25,10 +25,22 @@ export default function Card({ title, type, value, + handleSelectedOnClick, }: CardProps) { const { register } = useFormContext() + + function onLabelClick(event: React.MouseEvent) { + // Preventing click event on label elements firing twice: https://github.com/facebook/react/issues/14295 + event.preventDefault() + handleSelectedOnClick?.() + } return ( -