Skip to content

Fix transcript losing its bottom pin to keyboard/layout changes - #16

Open
PanAndDuck wants to merge 1 commit into
xintaofei:mainfrom
PanAndDuck:ios/fix-transcript-keyboard-scroll
Open

PanAndDuck wants to merge 1 commit into
xintaofei:mainfrom
PanAndDuck:ios/fix-transcript-keyboard-scroll

Conversation

@PanAndDuck

Copy link
Copy Markdown

Summary

  • Tapping the compose field (or sending a message while it's focused) could leave the newest message hidden behind the keyboard, and dismissing the keyboard wouldn't re-settle the scroll position either.
  • Root cause: the single geometry observer driving stuckToBottom treated ANY offset shift crossing the bottom threshold as "the user scrolled away" — including shifts caused by the keyboard shrinking the visible area, or by rows still finishing their layout. A keyboard show/hide could therefore silently unpin the transcript from the bottom it was actually still supposed to be following.
  • onScrollPhaseChange now distinguishes a genuine user-driven scroll (.tracking/.interacting/.decelerating) from a passive layout change. Only a real user scroll can unpin the viewport; while pinned, a content/container/inset size change (keyboard, compose-bar height, late row measurement) instead re-asserts the bottom anchor.

Test plan

  • Builds and runs on iOS Simulator
  • Screenshot-confirmed against a live server: newest message stays visible with the keyboard shown, transcript still tracks the bottom once the keyboard is dismissed, and a freshly-sent message scrolls into view

Tapping the compose field (or sending a message while it's focused)
could leave the newest message hidden behind the keyboard, and
dismissing the keyboard wouldn't re-settle the scroll either. Root
cause: the single geometry observer driving `stuckToBottom` treated
ANY offset shift that crossed the bottom threshold as "the user
scrolled away", including shifts caused by the keyboard shrinking the
visible area or by rows still finishing their layout — so a keyboard
show/hide routinely (and silently) unpinned the transcript from the
bottom it was actually still following.

`onScrollPhaseChange` now distinguishes a genuine user-driven scroll
(`.tracking`/`.interacting`/`.decelerating`) from a passive layout
change. Only a real user scroll may unpin the viewport; while pinned,
a content/container/inset size change (keyboard, compose-bar height,
late row measurement) instead re-asserts the bottom anchor.

Verified on Simulator with a live server: screenshots confirm the
newest message stays visible with the keyboard shown, the transcript
still tracks the bottom once it's dismissed, and a freshly-sent message
scrolls into view.
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.

1 participant