:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(lemon-ui): Render the group-level data-attr on LemonRadio (#105040)
Juraj Majerikbc814bdf56b3
diff --git a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.test.tsx b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.test.tsxnew file mode 100644index 000000000000..064c1ef87759--- /dev/null+++ b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.test.tsx@@ -0,0 +1,22 @@+import { render } from '@testing-library/react'++import { LemonRadio } from './LemonRadio'++describe('LemonRadio', () => {+ it('renders the group-level data-attr', () => {+ // Hyphenated JSX attributes skip TypeScript's excess property check, so a+ // silently dropped data-attr prop never fails typecheck.+ const { container } = render(+ <LemonRadio+ data-attr="my-radio-group"+ value="a"+ onChange={() => {}}+ options={[+ { value: 'a', label: 'A' },+ { value: 'b', label: 'B' },+ ]}+ />+ )+ expect(container.querySelector('[data-attr="my-radio-group"]')).not.toBeNull()+ })+})diff --git a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsxindex 0dc1827414e5..083f9574ae34 100644--- a/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx+++ b/frontend/src/lib/lemon-ui/LemonRadio/LemonRadio.tsx@@ -21,6 +21,7 @@ export interface LemonRadioProps<T extends React.Key> {orientation?: 'vertical' | 'horizontal'/** Accessible name for the radio group, announced by screen readers. */'aria-label'?: string+ 'data-attr'?: string}/** Single choice radio. */@@ -32,6 +33,7 @@ export function LemonRadio<T extends React.Key>({radioPosition,orientation = 'vertical','aria-label': ariaLabel,+ 'data-attr': dataAttr,}: LemonRadioProps<T>): JSX.Element {// A shared name makes the inputs one native radio group, so arrow keys move between them.const groupName = useId()@@ -39,6 +41,7 @@ export function LemonRadio<T extends React.Key>({<divrole="radiogroup"aria-label={ariaLabel}+ data-attr={dataAttr}className={clsx('flex font-medium',orientation === 'vertical' ? 'flex-col gap-2' : 'flex-row gap-4',