Skip to content

Commit

Permalink
fix: incorrect KeyboardStickyView state when keyboard animation int…
Browse files Browse the repository at this point in the history
…errupted (#704)

## 📜 Description

Fixed broken `KeyboardStickyView` position if keyboard dismissing has
been interrupted (by showing a native sheet, for example).

## 💡 Motivation and Context

This problem was discovered in
bluesky-social/social-app#6739

However I discovered such issue even earlier in
#667
- there I found out that progress can be interrupted (keyboard can start
its movement, but then will be interrupted and will be instantly hidden)
and `onEnd` event will be triggered.

Back to the times I fixed a problem by calling `maybeScroll` in `onEnd`
handler. in this PR I want to do a similar thing - the only difference
is that I want to add `onEnd` event to mapping for Animated/Reanimated
values (`useKeyboardAnimation`/`useReanimatedKeyboardAnimation` hooks).

A proper fix for bluesky-social/social-app#6739

## 📢 Changelog

### Android

- update `SharedValue` for `end` event on Android;
- update `Animated.Value` for `end` event on iOS;

## 🤔 How Has This Been Tested?

Tested on CI.

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Nov 26, 2024
1 parent a300735 commit 9b1f69a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/animated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ export const KeyboardProvider = ({

updateSharedValues(event, ["android", "ios"]);
},
onKeyboardMoveEnd: (event: NativeEvent) => {
"worklet";

updateSharedValues(event, ["android"]);
},
},
[],
);
Expand Down Expand Up @@ -213,6 +218,7 @@ export const KeyboardProvider = ({
onKeyboardMoveStart={OS === "ios" ? onKeyboardMove : undefined}
onKeyboardMove={OS === "android" ? onKeyboardMove : undefined}
onKeyboardMoveInteractive={onKeyboardMove}
onKeyboardMoveEnd={OS === "android" ? onKeyboardMove : undefined}
onFocusedInputLayoutChangedReanimated={inputLayoutHandler}
>
{children}
Expand Down

0 comments on commit 9b1f69a

Please sign in to comment.