fix(settings): make personalisation autosave lossless around "Other" boxes
WHY THIS MATTERS Two silent data-loss paths were replicated live during the PR #365 review of the new Personalisation settings page: 1. Tick "Other" under Practice areas and leave the text box empty, then change any OTHER field (e.g. Title -> Partner). Nothing is saved - no request fires, no status appears, and navigating away discards the change. The page-wide validationError guard paused the entire autosave effect, and the error string itself was never rendered, so the user had no way to know saving had stopped. 2. Pick a value (or finish typing) and click another Settings tab within the 400 ms debounce window. The effect cleanup cancelled the scheduled save on unmount, so the edit vanished. WHAT IS A DEBOUNCED AUTOSAVE EFFECT Each edit re-runs a React effect that schedules the PATCH 400 ms out; another edit inside that window cancels and reschedules. The cleanup that makes the rescheduling work is the same cleanup that runs on unmount - so without an explicit flush, leaving the page always cancels the last pending save. HOW THE FIX WORKS - The hook now reports WHICH field groups are mid-edit-invalid (invalidGroups) instead of a single page-wide error. The autosave effect only skips a save when the edited field's own group is invalid; for other fields it saves a payload in which the invalid groups fall back to their last persisted values, so a half-finished "Other" box can neither block unrelated saves nor overwrite its own stored value with a transient empty state. - The validation message is now rendered inline (aria-live), so a paused save is visible instead of silent. - The scheduled save closure is kept in a ref; the unmount cleanup fires it immediately instead of dropping it. Tests pin all three behaviours: unrelated-field saves proceed with the persisted fallback, the message renders, and unmount flushes the pending save. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RuPCULDYgVsiCanRgbEy6W
| Repository | open-legal-products/mike |
|---|---|
| Author | Amal <mamalanand3@gmail.com> |
| Authored | |
| Parents | 16d85463 |
| Stats | 3 files changed , +115 , -13 |
| Part of | Add Google sign-in and personalised onboarding |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-44adf584.md
from inside the repo you want the change in.