: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(signals): prevent refund submission when adding a newline (#107220)
posthog[bot]3d1dd420a6c5
diff --git a/products/signals/frontend/inbox/components/shell/RefundReportDialog.test.tsx b/products/signals/frontend/inbox/components/shell/RefundReportDialog.test.tsxnew file mode 100644index 000000000000..b6f4213286d9--- /dev/null+++ b/products/signals/frontend/inbox/components/shell/RefundReportDialog.test.tsx@@ -0,0 +1,46 @@+import '@testing-library/jest-dom'++import { act, screen, waitFor } from '@testing-library/react'+import userEvent from '@testing-library/user-event'++import { initKeaTests } from '~/test/init'++import { SignalReportRefundReasonEnumApi } from 'products/signals/frontend/generated/api.schemas'++import { openRefundReportDialog, RefundReportDialogResult } from './RefundReportDialog'++describe('openRefundReportDialog', () => {+ beforeEach(() => {+ initKeaTests()+ })++ afterEach(() => {+ document.body.innerHTML = ''+ })++ it.each([+ ['Enter', '{Enter}'],+ ['Shift+Enter', '{Shift>}{Enter}{/Shift}'],+ ])('inserts a newline on %s instead of submitting the refund', async (_, keys) => {+ const onConfirm = jest.fn<Promise<void>, [RefundReportDialogResult]>().mockResolvedValue(undefined)+ act(() => openRefundReportDialog({ reportTitle: 'A report', onConfirm }))++ await userEvent.click(await screen.findByText('Duplicate of work already covered'))+ const note = screen.getByPlaceholderText('Optional: add detail')+ await userEvent.click(note)+ await userEvent.keyboard('first line')+ await userEvent.keyboard(keys)+ await userEvent.keyboard('second line')++ expect(onConfirm).not.toHaveBeenCalled()+ expect(note).toHaveValue('first line\nsecond line')++ await userEvent.click(screen.getByText('Refund'))++ await waitFor(() => expect(onConfirm).toHaveBeenCalledTimes(1))+ expect(onConfirm).toHaveBeenCalledWith({+ reason: SignalReportRefundReasonEnumApi.Duplicate,+ note: 'first line\nsecond line',+ })+ })+})diff --git a/products/signals/frontend/inbox/components/shell/RefundReportDialog.tsx b/products/signals/frontend/inbox/components/shell/RefundReportDialog.tsxindex 70694a923b4d..f8704b787bf2 100644--- a/products/signals/frontend/inbox/components/shell/RefundReportDialog.tsx+++ b/products/signals/frontend/inbox/components/shell/RefundReportDialog.tsx@@ -56,7 +56,14 @@ export function openRefundReportDialog({ reportTitle, staysResolved, onConfirm })}</LemonField><LemonField name="note" label="Note" info="Optional. Helps us review refunds.">- <LemonTextArea placeholder="Optional: add detail" maxLength={4000} rows={3} />+ <LemonTextArea+ // stopPropagation keeps Enter in this multi-line note from reaching the dialog+ // form and refunding mid-sentence.+ stopPropagation+ placeholder="Optional: add detail"+ maxLength={4000}+ rows={3}+ /></LemonField></div>),