Fix false-positive unsaved-draft banner on client detail - #404
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
form_draft_guard.jstreated a form as dirty/draft-worthy whenever any field was non-blank. The client profile form'sintake_notes/case_notesfields prefill with a large boilerplate clinical-notes template when a client has none yet, so any incidentalinput/changeevent on the form (most likely browser autofill on the unguardedarbeitsdiagnosetext 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.autocomplete="off"toarbeitsdiagnoseas defense-in-depth against the likeliest stray trigger.Test plan
form_draft_guard.test.jsupdated 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