Skip to content

Fix false-positive unsaved-draft banner on client detail - #404

Merged
dholbach merged 1 commit into
mainfrom
fix/draft-guard-false-positive
Sep 1, 2026
Merged

Fix false-positive unsaved-draft banner on client detail#404
dholbach merged 1 commit into
mainfrom
fix/draft-guard-false-positive

Conversation

@dholbach

@dholbach dholbach commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • form_draft_guard.js treated a form as dirty/draft-worthy whenever any field was non-blank. The client profile form's intake_notes/case_notes fields prefill with a large boilerplate clinical-notes template when a client has none yet, so any incidental input/change event on the form (most likely browser autofill on the unguarded arbeitsdiagnose text field) caused the whole untouched form to be saved as a "draft" — and the restore banner then showed on every future visit, even with nothing actually edited.
  • Fixed by snapshotting field values as a baseline at page load and only treating the form as dirty / draft-worthy when current or stored values actually differ from that baseline, not merely "non-blank." Editing a field back to its original value now correctly clears dirty state and any saved draft.
  • Added autocomplete="off" to arbeitsdiagnose as defense-in-depth against the likeliest stray trigger.

Test plan

  • form_draft_guard.test.js updated to simulate real typing (value changes after page load) and extended with cases covering the exact bug (unchanged non-blank default doesn't trigger dirty/save; stored draft identical to current default is discarded rather than offered)
  • ./dev.py test --fast — Django + JS suites pass

🤖 Generated with Claude Code

https://claude.ai/code/session_01D8iNVtdtdXsK7D98UDMr8C

form_draft_guard.js flagged a form dirty/draft-worthy whenever any
field was non-blank, but the client profile form's notes fields
prefill with a large boilerplate template when a client has none yet
— so any incidental input/change event (e.g. browser autofill on the
unguarded arbeitsdiagnose field) saved the whole untouched form as a
"draft" and kept showing the restore banner forever after.

Compare field values against a baseline snapshot taken at load
instead, so only real edits count. Also mark arbeitsdiagnose
autocomplete="off" to remove the likeliest stray trigger.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8iNVtdtdXsK7D98UDMr8C
@dholbach
dholbach merged commit b72d1ae into main Sep 1, 2026
2 checks passed
@dholbach
dholbach deleted the fix/draft-guard-false-positive branch September 1, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant