fix(settings): drop the focused-input hydration guards, keep the effect split

↗ view on GitHub · Amal · 2026-08-21 · 8b5f3aef

WHY THIS MATTERS
An independent verifier measured that the focused-input guards added
with the hydration-effect split introduced their own data-loss bug:
if the profile finishes loading while the Display Name input is
focused, the guard skips the sync, the input stays empty, and merely
blurring the untouched field fires the autosave - comparing local ""
against the freshly loaded stored name and overwriting it with an
empty string. The same verifier proved empirically that the effect
SPLIT alone fixes the original sibling-clobber bug: a name save never
changes profile.organisation, so the organisation effect simply does
not run when the name save's profile refresh lands.

THE TEST WAS ALSO NOT PINNING ANYTHING
The previous regression test resolved the mocked save inside
user.click()'s microtask flush, so the race window never opened and
the test passed even against the unfixed combined effect. It now
holds the save in flight with a deferred promise, types into the
sibling field, and only then lets the profile refresh land - it fails
on the pre-fix code and passes on this one.

HOW THE FIX WORKS
Keep the two per-field effects (each keyed only to its own profile
value); remove the refs and document.activeElement checks. Simpler,
and strictly fewer failure modes.

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 c39f01ef
Stats 2 files changed , +31 , -17
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-8b5f3aef.md from inside the repo you want the change in.

⬇ Download capture-commit-8b5f3aef.md