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:
parent
47645ec115
commit
b650a94bb8
@ -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'));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user