From 15717f137ac5018e3de2b8422b51458cc1ff7ba6 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 24 Sep 2026 18:52:16 +0200 Subject: [PATCH] fix: keep what was typed in the event editor when calendars refresh The editor reset its form whenever `calendars` or `currentUserEmails` got a new identity, which happens when a calendar push refetches the calendars or the alias lookup finishes, so the title and times the user had typed were replaced mid-edit. Reset only when the editor opens or moves to another event, and fill in the calendar separately when the calendars arrive after a new-event form opened. --- src/components/calendar/EventModal.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/calendar/EventModal.tsx b/src/components/calendar/EventModal.tsx index 0983f4cb..07b5f496 100644 --- a/src/components/calendar/EventModal.tsx +++ b/src/components/calendar/EventModal.tsx @@ -228,6 +228,10 @@ export function EventModal({ const [showEndTime, setShowEndTime] = React.useState(false); const [saving, setSaving] = React.useState(false); + // Reset the form when the editor opens or switches to another event only. + // `calendars` and `currentUserEmails` get new identities when a calendar + // push or the alias lookup lands, which used to wipe what the user typed. + const formKey = visible ? event?.id ?? 'new' : null; React.useEffect(() => { if (!visible) return; if (event) { @@ -270,7 +274,13 @@ export function EventModal({ setLocation(''); setVideoUrl(''); } - }, [visible, event, defaultDate, fallbackCalendarId, calendars, currentUserEmails]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [formKey]); + + // The calendars can arrive after a new-event form opened. + React.useEffect(() => { + if (visible && !calendarId && fallbackCalendarId) setCalendarId(fallbackCalendarId); + }, [visible, calendarId, fallbackCalendarId]); React.useEffect(() => { if (allDay) {