: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(ui): open info tooltips on click (#115233)
Eleftheria Trivyzakie8cbf74e2762
diff --git a/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.test.tsx b/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.test.tsxnew file mode 100644index 000000000000..f644a1da3ffb--- /dev/null+++ b/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.test.tsx@@ -0,0 +1,27 @@+import { cleanup, fireEvent, render, screen } from '@testing-library/react'++import { LemonLabel } from './LemonLabel'++const INFO = 'Updates once daily.'++describe('LemonLabel', () => {+ afterEach(() => {+ cleanup()+ })++ it('opens the info tooltip on click without activating the labelled control', async () => {+ render(+ <div>+ <LemonLabel htmlFor="opt-in" info={INFO}>+ Opt in+ </LemonLabel>+ <input id="opt-in" type="checkbox" />+ </div>+ )++ fireEvent.click(screen.getByText('Opt in').querySelector('svg') as SVGElement)++ expect(await screen.findByText(INFO)).toBeTruthy()+ expect((screen.getByRole('checkbox') as HTMLInputElement).checked).toBe(false)+ })+})diff --git a/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx b/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsxindex 07ecc501f65c..7a87629a2c9a 100644--- a/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx+++ b/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx@@ -41,13 +41,18 @@ export function LemonLabel({) : null}{info ? (- <Tooltip title={info} interactive>+ <Tooltip title={info} interactive openOnClick={!infoLink}>{infoLink ? (<Link to={infoLink} target="_blank" className="inline-flex"><IconInfo className="text-xl text-secondary shrink-0" /></Link>) : (- <IconInfo className="text-xl text-secondary shrink-0" />+ <IconInfo+ className="text-xl text-secondary shrink-0"+ // The icon sits inside the <label>, so a click would also activate the+ // htmlFor control and toggle a checkbox the reader only wanted explained+ onClick={(e) => e.preventDefault()}+ />)}</Tooltip>) : null}