When creating a doc with more than one radio, unique ids are not created for each set of radios. The problem is you can't set default radio form values for the subsequent controls.
To Reproduce
Using the next/typescript sandbox, I updated the Button.tsx file to take two props with a set of choices. The autodocs generate two radio groups and you can see the ids are the same between each group. control-type-{n}
import React from 'react';
import './button.css';
interface ButtonProps {
/**
* Is this the principal call to action on the page?
*/
primary?: boolean;
/**
* What background color to use
*/
backgroundColor?: string;
/**
* How large should the button be?
*/
size?: 'small' | 'medium' | 'large';
/**
* How large should the button be?
*/
type?: 'primary' | 'secondary' | 'tertiary';
/**
* Button contents
*/
label: string;
/**
* Optional click handler
*/
onClick?: () => void;
}
/**
* Primary UI component for user interaction
*/
export const Button = ({
primary = false,
size = 'medium',
type = 'primary',
backgroundColor,
label,
...props
}: ButtonProps) => {
const mode =
type === 'primary'
? 'storybook-button--primary'
: type === 'secondary'
? 'storybook-button--secondary'
: 'storybook-button--tertiary';
return (
<button
type="button"
className={['storybook-button', `storybook-button--${size}`, mode].join(
' '
)}
{...props}
>
{label}
<style jsx>{`
button {
background-color: ${backgroundColor};
}
`}</style>
</button>
);
};
Describe the bug
When creating a doc with more than one radio, unique ids are not created for each set of radios. The problem is you can't set default radio form values for the subsequent controls.
To Reproduce
Using the next/typescript sandbox, I updated the Button.tsx file to take two props with a set of choices. The autodocs generate two radio groups and you can see the ids are the same between each group.
control-type-{n}
System
Additional context
No response