fix: keep iOS keyboard height in sync#341
Conversation
Sentry Preview Error TriageNo Sentry errors found for this PR's preview deployment as of Tue, 23 Jun 2026 16:48:13 GMT. This comment updates automatically after each push. |
Deploying with
|
| Status | Preview URL | Commit | Alias | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! | https://pr-341-charm.justin-tech.workers.dev | 684b6e7 | pr-341 |
Tue, 23 Jun 2026 16:50:13 GMT |
Code Coverage OverviewLanguages: JavaScript JavaScript / code-coverage/vitestThe overall coverage in the branch remains at 27%, unchanged from the branch. Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06634282a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setCSSVars( | ||
| getImmediateVisibleViewportHeight( | ||
| baselineHeight, | ||
| viewport.height, | ||
| sharedSavedHeight, | ||
| cssVarsApplied | ||
| ) | ||
| ); |
There was a problem hiding this comment.
Preserve the saved-height estimate across all listeners
With the normal room screen, multiple useKeyboardHeight instances are mounted (RoomView, RoomTimeline, and RoomInput all call it), so all of their visualViewport.resize handlers run for the same first keyboard-open resize. The first handler sets cssVarsApplied = true inside setCSSVars, then later handlers reach this unconditional call with varsAlreadyApplied true and overwrite the saved-height estimate with the transient live viewport height, defeating the first-open estimate that avoids composer/timeline jumps. Consider only switching to live viewport updates when the variable was already applied before this resize event, or otherwise keep the shared estimate until the open stabilizes.
Useful? React with 👍 / 👎.
Description
Keep the mobile composer pinned to the live iOS visual viewport height while switching between keyboard modes such as text and emoji. This updates the synchronous CSS-height path in the iOS keyboard hook and adds a unit test for the immediate viewport-height selection logic.
Fixes #336
Type of change
Checklist:
AI disclosure:
This patch changes
useKeyboardHeightso--sable-visible-heightkeeps following the livevisualViewport.heighteven after the keyboard is already open, which prevents stale height values from leaving a gap when iOS switches between text and emoji keyboards. It also extracts the immediate-height selection into a small helper and adds a focused unit test covering first-open estimation, no-estimate fallback, and already-open keyboard mode changes.