Skip to content

fix: start a new event from the "+" button on a day the calendar shows #139 - #140

Merged
rathlinus merged 1 commit into
bulwarkmail:mainfrom
wmcparla:fix/new-event-on-shown-day-139
Nov 15, 2026
Merged

rathlinus merged 1 commit into
bulwarkmail:mainfrom
wmcparla:fix/new-event-on-shown-day-139

Conversation

@wmcparla

Copy link
Copy Markdown
Contributor

Summary

In the calendar, "+" opened the new-event editor on the selected day, and swiping a view does not move the selection. So after swiping the day view to 22 November, "+" still offered today (#139). The week and multi-day grids and the month did the same once scrolled away from the selected day.

"+" now starts the event on the selected day while that day is on screen, and otherwise on the first day the view shows: the day in the day view, the first column of the week and multi-day grids, and in the month the 1st of the month in the title (or that month's first day still on screen when the 1st has scrolled off the top). The schedule is unchanged.

Two related things in the same line of code:

  • The start time came from the moment the day was selected, not from the clock: the second screenshot in [Bug]: Incorrect default date when adding event in day view via "+" #139 was taken at 12:47 and offers 12:00. It is now the next half hour from the time "+" is pressed, on whichever day the event starts.
  • Because of that, a day picked earlier (a tapped month day, the month panel) no longer opens at 00:00 from "+". After 23:30 the start is held at 23:30, so rounding up cannot move the event to the next day.

Changes

  • src/lib/calendar-new-event.ts (new): shownDays() gives the days a view has on screen and the day an event starts on there; newEventStart() picks the selected day or that one, at the clock's time.
  • src/screens/CalendarScreen.tsx: the "+" button uses them. A day reported by a scrolling view is ignored once free scrolling is off.
  • src/components/calendar/MonthScrollView.tsx: reports the rows in view (onVisibleRowsChange), since the month in the title turns before the previous month's rows have left the screen. The screen keeps them in a ref, so scrolling causes no extra render.
  • src/lib/__tests__/calendar-new-event.test.ts: 13 cases, among them the [Bug]: Incorrect default date when adding event in day view via "+" #139 case, the late-evening hold, a selected day of the previous month still on screen, stale month rows after a jump, and the Jalali month.

Related issues

Closes #139

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactor / code quality improvement
  • Chore / dependency update / CI change

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style and conventions
  • npx tsc --noEmit, npx vitest run and npm run i18n:check are clean (this repo has no lint or build script)
  • I have tested my changes locally
  • I have added or updated documentation if needed (none needed)
  • I have updated translations (no new strings)
  • I have included screenshots or a screen recording for UI changes

How it was tested

On an Android 16 phone emulator, with a test account on a self-hosted Stalwart 1.1.0, the same scripted run against main at b3b4230 and against this branch. It scrolls a view, presses "+", reads the start date in the editor and closes it without saving.

Step main This branch
Day view on today (14 Nov) Sat, Nov 14 Sat, Nov 14
Day view swiped eight days on Sat, Nov 14 Sun, Nov 22
One swipe back Sat, Nov 14 Sat, Nov 21
Week view on this week Sat, Nov 14 Sat, Nov 14
Week view scrolled to 23-29 Nov Sat, Nov 14 Mon, Nov 23
Month view on this month Sat, Nov 14 Sat, Nov 14
25 Nov picked in the month panel, month scrolled until the title reads December, 25 Nov still on screen Wed, Nov 25 Wed, Nov 25
Month scrolled on to a later month Wed, Nov 25 the first day on screen of the month in the title (Mon, Mar 1 in this run)
Schedule Sat, Nov 14 Sat, Nov 14

Not run on a device: iOS (the reporter's platform; the code is shared and has no platform branch), the multi-day view, a tablet, free scrolling turned off, a right-to-left layout and the late-evening hold. The unit tests cover the multi-day range and the hold.

Screenshots

The day view swiped to 22 November, and the editor "+" opens there on this branch:

Day view New event

🤖 Generated with Claude Code

@wmcparla
wmcparla marked this pull request as ready for review November 14, 2026 12:43
@rathlinus
rathlinus merged commit aecb320 into bulwarkmail:main Nov 15, 2026
1 check passed
@rathlinus

Copy link
Copy Markdown
Member

Thanks, merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect default date when adding event in day view via "+"

2 participants