fix: replace reset useEffects with key prop for step component remount

The reset useEffects in StepOrientation/Deskew/Dewarp/Crop were clearing
orientationResult when sessionId changed (e.g. during handleOrientationComplete),
causing the right side of ImageCompareView to show nothing. Using key={sessionId}
on the step components instead forces React to remount with fresh state when
switching sessions, without interfering with the upload/orientation flow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-24 12:20:50 +01:00
parent 08a91ba2be
commit 63dfb4d06f
6 changed files with 12 additions and 42 deletions

View File

@@ -17,13 +17,6 @@ export function StepCrop({ sessionId, onNext }: StepCropProps) {
const [error, setError] = useState<string | null>(null)
const [hasRun, setHasRun] = useState(false)
// Reset state when sessionId changes (e.g. switching sub-sessions)
useEffect(() => {
setCropResult(null)
setHasRun(false)
setError(null)
}, [sessionId])
// Auto-trigger crop on mount
useEffect(() => {
if (!sessionId || hasRun) return

View File

@@ -22,14 +22,6 @@ export function StepDeskew({ sessionId, onNext }: StepDeskewProps) {
const [error, setError] = useState<string | null>(null)
const [hasAutoRun, setHasAutoRun] = useState(false)
// Reset state when sessionId changes (e.g. switching sub-sessions)
useEffect(() => {
setSession(null)
setDeskewResult(null)
setHasAutoRun(false)
setError(null)
}, [sessionId])
// Load session and auto-trigger deskew
useEffect(() => {
if (!sessionId || session) return

View File

@@ -20,13 +20,6 @@ export function StepDewarp({ sessionId, onNext }: StepDewarpProps) {
const [showGrid, setShowGrid] = useState(true)
const [error, setError] = useState<string | null>(null)
// Reset state when sessionId changes (e.g. switching sub-sessions)
useEffect(() => {
setDewarpResult(null)
setDeskewResult(null)
setError(null)
}, [sessionId])
// Load session info to get deskew_result (for fine-tuning init values)
useEffect(() => {
if (!sessionId) return

View File

@@ -30,14 +30,6 @@ export function StepOrientation({ sessionId: existingSessionId, onNext, onSubSes
const [dragOver, setDragOver] = useState(false)
const [sessionName, setSessionName] = useState('')
// Reset state when sessionId changes
useEffect(() => {
setSession(null)
setOrientationResult(null)
setPageSplitResult(null)
setError(null)
}, [existingSessionId])
// Reload session data when navigating back
useEffect(() => {
if (!existingSessionId || session) return