Skip to content

Conversation

michael-pingo-ai
Copy link

@michael-pingo-ai michael-pingo-ai commented Oct 3, 2025

Please provide enough information so that others can review your pull request:

Motivation

Explain the motivation for making this change. What existing problem does the pull request solve?

This PR fixes a bug where the bottom sheet could assign a raw position value to index when the keyboard was shown. This caused animatedCurrentIndex to be set to invalid values (e.g. 235), which led to broken state and the sheet height not resetting when the keyboard was dismissed.

The fix ensures index is resolved against the detents array, falling back to DEFAULT_KEYBOARD_INDEX if no match is found.

Solves:
#2509
#2465
#2460

position !== closedDetentPosition
) {
index = highestDetentPosition ?? DEFAULT_KEYBOARD_INDEX;
index = detents?.indexOf(highestDetentPosition ?? 0) ?? DEFAULT_KEYBOARD_INDEX;
Copy link

@AgustinMJ AgustinMJ Oct 7, 2025

Choose a reason for hiding this comment

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

Just found the same bug and was about to open the same pr😁

I think it is better to just get the last item of the array since we know they are sorted in ascending order, right?

Suggested change
index = detents?.indexOf(highestDetentPosition ?? 0) ?? DEFAULT_KEYBOARD_INDEX;
index = detents?.length ? detents.length - 1 : DEFAULT_KEYBOARD_INDEX;

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.

2 participants