From b650a94bb8500e5cd837650ecbb93e3726dd3474 Mon Sep 17 00:00:00 2001 From: Kyle Pope Date: Fri, 6 Mar 2026 02:05:49 +0800 Subject: [PATCH] Fix birthday DatePicker stale closure in Settings profile save The onBlur handler captured the stale dateOfBirth value from before onChange updated state, causing the equality guard to silently abort the save. Fixed by saving inline in onChange with the fresh value and removing onBlur/onKeyDown from the DatePicker. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/settings/SettingsPage.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/settings/SettingsPage.tsx b/frontend/src/components/settings/SettingsPage.tsx index e76e550..a6fd474 100644 --- a/frontend/src/components/settings/SettingsPage.tsx +++ b/frontend/src/components/settings/SettingsPage.tsx @@ -437,9 +437,15 @@ export default function SettingsPage() { variant="input" id="date_of_birth" value={dateOfBirth} - onChange={(v) => setDateOfBirth(v)} - onBlur={() => handleProfileSave('date_of_birth')} - onKeyDown={(e) => { if (e.key === 'Enter') handleProfileSave('date_of_birth'); }} + onChange={(v) => { + setDateOfBirth(v); + const orig = profileQuery.data?.date_of_birth ?? ''; + if (v.trim() !== (orig || '')) { + api.put('/auth/profile', { date_of_birth: v.trim() || null }) + .then(() => { queryClient.invalidateQueries({ queryKey: ['profile'] }); toast.success('Profile updated'); }) + .catch(() => toast.error('Failed to update profile')); + } + }} />