Skip to content

fix: do not block mount animation when only keyboard is animating (#2661)#2665

Merged
gorhom merged 1 commit into
gorhom:masterfrom
huextrat:fix/mount-animation-keyboard-2661
May 9, 2026
Merged

fix: do not block mount animation when only keyboard is animating (#2661)#2665
gorhom merged 1 commit into
gorhom:masterfrom
huextrat:fix/mount-animation-keyboard-2661

Conversation

@huextrat
Copy link
Copy Markdown
Contributor

@huextrat huextrat commented Apr 30, 2026

Problem

Fixes #2661

With BottomSheetModal + BottomSheetTextInput + autoFocus, the keyboard can open while didAnimateOnMount is still false. In that situation the sheet content can stay behind the keyboard. Focusing manually after the sheet is open (or after onChange) avoids the issue—a race between mount and keyboard animations.

Root cause

PR #2655 (ad41447, v5.2.10) added an early return in evaluatePosition for the mount phase:

if (!didAnimateOnMount.value) {
  if (animationStatus === ANIMATION_STATUS.RUNNING) {
    return;
  }
  // mount animation...
}

That correctly prevents the mount animation from overriding a close animation (e.g. forceClose), but it also treats any running animation the same way—including keyboard repositioning triggered by autoFocus. The mount path then never runs, and the sheet ends up misaligned with the keyboard.

Fix

Only skip the mount animation when a close is in progress:

  • isForcedClosing (force close / modal dismiss path), or
  • nextIndex === -1 (animating to the closed detent).

If the only RUNNING animation is keyboard-driven (nextIndex typically ≥ 0), the mount animation is not blocked.

Testing

Related

…rhom#2661)

The gorhom#2655 guard skipped any RUNNING animation before didAnimateOnMount,
which includes keyboard repositioning when TextInput autoFocus opens the
keyboard immediately. Only skip mount when a close is in progress
(isForcedClosing or nextIndex === -1).

Made-with: Cursor
@huextrat huextrat marked this pull request as ready for review April 30, 2026 06:33
@dorupopacaliman
Copy link
Copy Markdown

Confirming the patch works, this needs to be released.

@gorhom gorhom self-assigned this May 9, 2026
Copy link
Copy Markdown
Owner

@gorhom gorhom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @huextrat for submitting this PR

@gorhom gorhom merged commit 782e00c into gorhom:master May 9, 2026
1 check failed
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]: Keyboard overlapping bottom sheet with autofocus

3 participants