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 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-03-06 02:05:49 +08:00
parent 47645ec115
commit b650a94bb8

View File

@ -437,9 +437,15 @@ export default function SettingsPage() {
variant="input" variant="input"
id="date_of_birth" id="date_of_birth"
value={dateOfBirth} value={dateOfBirth}
onChange={(v) => setDateOfBirth(v)} onChange={(v) => {
onBlur={() => handleProfileSave('date_of_birth')} setDateOfBirth(v);
onKeyDown={(e) => { if (e.key === 'Enter') handleProfileSave('date_of_birth'); }} 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'));
}
}}
/> />
</div> </div>
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-2 gap-3">