Skip to content

fix: animated day header shows wrong date while scrolling (#2709)#2746

Merged
kesha-antonov merged 1 commit into
masterfrom
fix/dayanimated-wrong-date
Jun 18, 2026
Merged

fix: animated day header shows wrong date while scrolling (#2709)#2746
kesha-antonov merged 1 commit into
masterfrom
fix/dayanimated-wrong-date

Conversation

@kesha-antonov

Copy link
Copy Markdown
Collaborator

Fixes #2709

Problem

While scrolling a chat with messages across multiple days, the floating animated day header could show the wrong date (e.g. the previous day) for the message group in view, even though the inline day separators were correct.

Root cause

The header's date was selected with a different threshold than its position:

  • Position (currentDayPosition): dayPosition = day.y + day.height
  • Date (createdAtDate): dayPosition = day.y + day.height − containerHeight − dayBottomMargin

So the date switched at a different scroll point than the header's visual transition → off-by-one-day mismatch.

Fix

Align the date selection with the position logic - same day.y + day.height threshold and same last-item fallback.

Validation (Android simulator, multi-day chat)

  • Floating header shows "10 June" over the 10 June group ✅
  • Floating header shows "17 June" over the 17 June group ✅
  • Tracks correctly across the day boundary, no off-by-one ✅

tsc, eslint, build pass locally; CI (Node 22 & 24) gates this PR.

The floating day header picked its date with a different threshold
(`day.y + day.height - containerHeight - dayBottomMargin`) than the one
that drives its vertical position (`currentDayPosition`, which uses
`day.y + day.height`). The mismatch made the displayed date switch at a
different scroll point than the header's visual transition, so it could
show the adjacent day's date (e.g. the previous day) for the group in view.

Align the date selection with the position logic: same `day.y + day.height`
threshold and the same last-item fallback.
@kesha-antonov kesha-antonov merged commit c2fb1c9 into master Jun 18, 2026
2 checks passed
@kesha-antonov kesha-antonov deleted the fix/dayanimated-wrong-date branch June 18, 2026 12:28
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.

Animated Day component shows incorrect date while scrolling messages (GiftedChat v3.2.3)

1 participant