Auto-rebuild grid when IPA or syllable mode dropdown changes
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 25s
CI / test-go-edu-search (push) Successful in 27s
CI / test-python-klausur (push) Failing after 2m0s
CI / test-python-agent-core (push) Successful in 15s
CI / test-nodejs-website (push) Successful in 15s
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 25s
CI / test-go-edu-search (push) Successful in 27s
CI / test-python-klausur (push) Failing after 2m0s
CI / test-python-agent-core (push) Successful in 15s
CI / test-nodejs-website (push) Successful in 15s
The dropdowns only updated state but didn't trigger buildGrid(). Now a useEffect watches ipaMode/syllableMode and rebuilds automatically (skipping the initial mount). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import type { StructuredGrid, GridZone, LayoutDividers } from './types'
|
import type { StructuredGrid, GridZone, LayoutDividers } from './types'
|
||||||
|
|
||||||
const KLAUSUR_API = '/klausur-api'
|
const KLAUSUR_API = '/klausur-api'
|
||||||
@@ -101,6 +101,19 @@ export function useGridEditor(sessionId: string | null) {
|
|||||||
}
|
}
|
||||||
}, [sessionId, buildGrid])
|
}, [sessionId, buildGrid])
|
||||||
|
|
||||||
|
// Auto-rebuild when IPA or syllable mode changes (skip initial mount)
|
||||||
|
const initialLoadDone = useRef(false)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!initialLoadDone.current) {
|
||||||
|
// Mark as initialized once the first grid is loaded
|
||||||
|
if (grid) initialLoadDone.current = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Mode changed after initial load — rebuild
|
||||||
|
buildGrid()
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [ipaMode, syllableMode])
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Save
|
// Save
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user