-
-
Notifications
You must be signed in to change notification settings - Fork 608
Back button error fix #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,13 @@ import { | |
| } from '@/components/ui/card'; | ||
| import { Button } from '@/components/ui/button'; | ||
| import { FolderOpen, X, Folder } from 'lucide-react'; | ||
| import { useDispatch } from 'react-redux'; | ||
| import { AppDispatch } from '@/app/store'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
| import { AppDispatch, RootState } from '@/app/store'; | ||
| import { markCompleted, previousStep } from '@/features/onboardingSlice'; | ||
| import { AppFeatures } from '@/components/OnboardingSteps/AppFeatures'; | ||
| import { useFolder } from '@/hooks/useFolder'; | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import { setIsEditing } from '@/features/onboardingSlice'; | ||
| interface FolderSetupStepProps { | ||
| stepIndex: number; | ||
| totalSteps: number; | ||
|
|
@@ -31,9 +31,12 @@ export function FolderSetupStep({ | |
|
|
||
| // Local state for folders | ||
| const [folder, setFolder] = useState<string>(''); | ||
| const isEditing = useSelector( | ||
| (state: RootState) => state.onboarding.isEditing, | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (localStorage.getItem('folderChosen') === 'true') { | ||
| if (localStorage.getItem('folderChosen') === 'true' && !isEditing) { | ||
| dispatch(markCompleted(stepIndex)); | ||
| } | ||
| }, []); | ||
|
Comment on lines
38
to
42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete editing mode cycle - same issue as AvatarSelectionStep. This component has the same two issues found in
This creates a one-way state change where editing mode, once activated, never deactivates. Consider the same fixes suggested for
Also applies to: 59-68 🤖 Prompt for AI Agents |
||
|
|
@@ -60,10 +63,11 @@ export function FolderSetupStep({ | |
| }; | ||
|
|
||
| const handleBack = () => { | ||
| dispatch(setIsEditing(true)); | ||
| dispatch(previousStep()); | ||
| }; | ||
|
|
||
| if (localStorage.getItem('folderChosen') === 'true') { | ||
| if (localStorage.getItem('folderChosen') === 'true' && !isEditing) { | ||
| return null; | ||
| } | ||
| const progressPercent = Math.round( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,10 @@ import { Sun, Moon, Monitor } from 'lucide-react'; | |
|
|
||
| import { AppFeatures } from '@/components/OnboardingSteps/AppFeatures'; | ||
| import { useTheme } from '@/contexts/ThemeContext'; | ||
|
|
||
| import { setIsEditing } from '@/features/onboardingSlice'; | ||
| import { useSelector } from 'react-redux'; | ||
| import { RootState } from '@/app/store'; | ||
| interface ThemeSelectionStepProps { | ||
| stepIndex: number; | ||
| totalSteps: number; | ||
|
|
@@ -30,10 +34,13 @@ export const ThemeSelectionStep: React.FC<ThemeSelectionStepProps> = ({ | |
| currentStepDisplayIndex, | ||
| }) => { | ||
| const { setTheme, theme } = useTheme(); | ||
| const isEditing = useSelector( | ||
| (state: RootState) => state.onboarding.isEditing, | ||
| ); | ||
| const dispatch = useDispatch<AppDispatch>(); | ||
|
|
||
| useEffect(() => { | ||
| if (localStorage.getItem('themeChosen')) { | ||
| if (localStorage.getItem('themeChosen') === 'true' && !isEditing) { | ||
| dispatch(markCompleted(stepIndex)); | ||
| } | ||
| }, []); | ||
|
Comment on lines
42
to
46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete editing mode cycle - consistent across all step components. This is the third step component with the same two issues:
Impact: Once a user clicks "Back" from any step, Recommendation: Establish a clear editing mode lifecycle. Consider one of these approaches:
Also applies to: 51-59 🤖 Prompt for AI Agents |
||
|
|
@@ -47,9 +54,10 @@ export const ThemeSelectionStep: React.FC<ThemeSelectionStepProps> = ({ | |
| }; | ||
|
|
||
| const handleBack = () => { | ||
| dispatch(setIsEditing(true)); | ||
| dispatch(previousStep()); | ||
| }; | ||
| if (localStorage.getItem('themeChosen')) { | ||
| if (localStorage.getItem('themeChosen') === 'true' && !isEditing) { | ||
| return null; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing useEffect dependency and incomplete editing cycle.
Two concerns with this useEffect:
Missing dependency: The effect uses
isEditingbut doesn't include it in the dependency array. If the component re-mounts whileisEditingis true, the effect won't reflect the current editing state correctly.Incomplete editing cycle: When users click "Next" after editing (via
handleNextClick),isEditingis never reset tofalse. This means once editing mode is activated, it stays active indefinitely, potentially affecting subsequent navigation.🔎 Suggested fixes
Option 1: Add isEditing to dependencies
useEffect(() => { if ( localStorage.getItem('name') && localStorage.getItem('avatar') && !isEditing ) { dispatch(markCompleted(stepIndex)); } - }, []); + }, [isEditing, dispatch, stepIndex]);Option 2: Reset isEditing when completing the step
const handleNextClick = () => { dispatch(setName(name)); dispatch(setAvatar(selectedAvatar)); localStorage.setItem('name', name); localStorage.setItem('avatar', selectedAvatar); + dispatch(setIsEditing(false)); dispatch(markCompleted(stepIndex)); };Consider whether the editing mode should persist across steps or reset when moving forward.
📝 Committable suggestion
🤖 Prompt for AI Agents