Bug: TemplateDetailAnalytics does not reset state when draftId changes
File: src/pages/TemplateDetailAnalytics.jsx:82-88
Problem
The useEffect that fetches detail and submissions depends on fetchDetail and fetchSubmissions, which are useCallback functions dependent on draftId. However, when navigating from one template to another (changing draftId), the component does not reset error, githubData, githubError, or submissionsPage:
useEffect(() => {
(async () => {
setLoading(true);
await Promise.all([fetchDetail(), fetchSubmissions(1)]);
setLoading(false);
})();
}, [fetchDetail, fetchSubmissions]);
Impact
- If template A had an error and user navigates to template B, the error banner from A persists
- GitHub data from template A shows until user clicks "Load Analysis" for template B
- Submissions page number doesn't reset to 1
Fix
Reset all state when draftId changes:
useEffect(() => {
setError(null);
setGithubData(null);
setGithubError(null);
setSubmissionsPage(1);
(async () => {
setLoading(true);
await Promise.all([fetchDetail(), fetchSubmissions(1)]);
setLoading(false);
})();
}, [fetchDetail, fetchSubmissions]);
Severity
Low-Medium — UI shows stale data from previous template. Not a crash but confusing UX.
Phase
Introduced in Phase 2 (PR #27, merged). Also affects Phase 3 GitHub section.
Bug: TemplateDetailAnalytics does not reset state when draftId changes
File:
src/pages/TemplateDetailAnalytics.jsx:82-88Problem
The
useEffectthat fetches detail and submissions depends onfetchDetailandfetchSubmissions, which areuseCallbackfunctions dependent ondraftId. However, when navigating from one template to another (changingdraftId), the component does not reseterror,githubData,githubError, orsubmissionsPage:Impact
Fix
Reset all state when
draftIdchanges:Severity
Low-Medium — UI shows stale data from previous template. Not a crash but confusing UX.
Phase
Introduced in Phase 2 (PR #27, merged). Also affects Phase 3 GitHub section.