Skip to content

Commit 5b92cf8

Browse files
committed
fix(hostConfig): clear JsonRecordEditor error on unmount
When the owner prop changes (e.g. to "connection-only") the host-context JsonRecordEditor unmounts but its error state in the parent (hostCtxError) was never cleared. The aggregated hasError signal stayed true and onValidityChange kept Save disabled with no visible error in the UI for the user to fix. Add a cleanup effect inside JsonRecordEditor that calls onErrorChange(null) on unmount. Generalizes to any section that becomes hidden — the parent's per-section error state mirrors only sections that are currently rendered. https://claude.ai/code/session_01FjxdHVhJba5KpLjXiiuuCu
1 parent 4b9127e commit 5b92cf8

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

mcpjam-inspector/client/src/components/host-config/HostConfigEditor.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,19 @@ function JsonRecordEditor({
469469
lastValueRef.current = value;
470470
}, [value, stringified, error, setError]);
471471

472+
// Clear the error signal when this editor unmounts (e.g. owner
473+
// switched to a mode that hides this section). Without this, the
474+
// parent's aggregated hasError signal would stay stuck on a stale
475+
// error from a section the user can no longer see, keeping Save
476+
// disabled with no visible cause to fix.
477+
useEffect(() => {
478+
return () => {
479+
onErrorChange?.(null);
480+
};
481+
// We intentionally don't depend on onErrorChange — only fire on unmount.
482+
// eslint-disable-next-line react-hooks/exhaustive-deps
483+
}, []);
484+
472485
// Parse on every keystroke so errors clear as soon as the user fixes
473486
// them and the parent's `onChange`/`onErrorChange` signals stay live.
474487
// We still only call `onChange` (committing the parsed value) on

0 commit comments

Comments
 (0)