Skip to content

Commit

Permalink
fix: for RadioCard allow optional onClick to allow single-line radio …
Browse files Browse the repository at this point in the history
…without selection
  • Loading branch information
peter-sanderson committed Feb 5, 2025
1 parent 07d9da1 commit 126ad48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/components/src/components/RadioCard/RadioCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type AllowedFrameProps = Pick<FrameProps, (typeof allowedRadioCardFrameProps)[nu
export type RadioCardProps = {
isActive: boolean;
children: ReactNode;
onClick: () => void;
onClick?: () => void;
} & AllowedFrameProps;

const Wrapper = styled.div<{ $isActive: boolean } & TransientProps<AllowedFrameProps>>`
Expand All @@ -35,7 +35,8 @@ const Wrapper = styled.div<{ $isActive: boolean } & TransientProps<AllowedFrameP
padding: ${spacingsPx.md};
outline: ${borders.widths.small} solid ${({ theme }) => theme.borderFocus};
outline-offset: -${borders.widths.small};
cursor: pointer;
${({ onClick }) => onClick && 'cursor: pointer;'}
&:hover,
&:focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ export const DecreasedOutputs = () => {
// it's safe to use array index as key since outputs do not change
<RadioCard
key={i}
onClick={() => {
if (useRadio) {
setValue('setMaxOutputId', i);
composeRequest();
}
}}
onClick={
useRadio
? () => {
setValue('setMaxOutputId', i);
composeRequest();
}
: undefined
}
isActive={useRadio && isChecked}
>
<Row gap={spacings.sm}>
Expand Down

0 comments on commit 126ad48

Please sign in to comment.