fix: show success message on bug report submission - #1512
Conversation
The form showed an error even when the GitHub issue was created successfully, because onSuccess checked response.data?.state === 'open' which didn't match the actual API response shape. Now the form resets and shows success on any successful API call, with a fallback message when the issue URL isn't available in the response. Closes hasadna#1431 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes the bug report form UX by ensuring a success state is shown after a successful GitHub issue creation request, without relying on an incorrect response.data.state === 'open' check.
Changes:
- Reset the AntD form on any successful mutation (removed
state === 'open'gate). - Always show a success
Alertonmutation.isSuccess, with a fallback message when the issue URL is missing. - Keep the “view issue” link behavior when a URL is available.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </a> | ||
| {mutation.data?.data?.url ? ( | ||
| <a href={mutation.data.data.url} target="_blank" rel="noopener noreferrer"> | ||
| {t('reportBug.viewIssue')} (Github) |
There was a problem hiding this comment.
The link label uses "Github"; the correct brand capitalization is "GitHub" (and other strings in the repo use "GitHub"). Please update the text to avoid inconsistent UI copy.
| {t('reportBug.viewIssue')} (Github) | |
| {t('reportBug.viewIssue')} (GitHub) |
| {t('reportBug.viewIssue')} (Github) | ||
| </a> | ||
| ) : ( | ||
| t('reportBug.success', { defaultValue: 'Bug report submitted successfully!' }) |
There was a problem hiding this comment.
t('reportBug.success', { defaultValue: ... }) hardcodes an English fallback even though reportBug.success is already defined in the locale JSON files. Consider using t('reportBug.success') to keep the message fully controlled by translations (and avoid accidental English text in non-English locales if the key changes).
| t('reportBug.success', { defaultValue: 'Bug report submitted successfully!' }) | |
| t('reportBug.success') |
|
Hi Eran! Thank you for your contribution. The fix is correct. The original code had One minor issue: the fallback string uses I hope I'll have the time to review it myself this weekend. Meanwhile, please make sure that your code is well-written and tested. |
NoamGaash
left a comment
There was a problem hiding this comment.
You have mentioned a "Test plan" in your PR description and it seems like you didn't finish testing - please complete your PR and ask for a review once you feel it's ready.
Personally, I'd love to see a Playwright tests here that mocks the backend endpoint and cover both successful form submission and error use case. We can even make a visual test out of it.
Thanks!
|
Great idea @NoamGaash — I'll add Playwright tests that mock the backend endpoint and cover both successful form submission and error cases. Will update this PR. |
|
Re-submitting from upstream branch (not fork) so previews and visual tests can run. |
Summary
The bug report form showed an error message even when the GitHub issue was created successfully. The
onSuccesshandler checkedresponse.data?.state === 'open'which didn't match the actual API response structure.state === 'open'check — form now resets on any successful API callCloses #1431
Test plan
Note:
tests/bugReport.spec.tsalready has E2E tests for both success (bug submission success) and error (bug submission server error) use cases with mocked backend endpoints.🤖 Generated with Claude Code