Skip to content

Commit

Permalink
fix: fixed keyboard dismissing issue with Reanimated v3 (#1346)(by @j…
Browse files Browse the repository at this point in the history
…anicduplessis)

* Fix reanimated freezing Keyboard module
  • Loading branch information
gorhom committed Apr 30, 2023
1 parent 9c5af58 commit 94cf11e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from '@gorhom/bottom-sheet';
import { useGestureTranslationY } from './GestureTranslationContext';

const dismissKeyboardOnJs = runOnJS(Keyboard.dismiss);

export const useCustomGestureEventsHandlers = () => {
// hooks
const gestureTranslationY = useGestureTranslationY();
Expand Down Expand Up @@ -266,7 +268,7 @@ export const useCustomGestureEventsHandlers = () => {
absoluteY > WINDOW_HEIGHT - animatedKeyboardHeight.value
)
) {
runOnJS(Keyboard.dismiss)();
dismissKeyboardOnJs();
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useGestureEventsHandlersDefault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type GestureEventContextType = {
isScrollablePositionLocked: boolean;
};

const dismissKeyboardOnJs = runOnJS(Keyboard.dismiss);

export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
() => {
//#region variables
Expand Down Expand Up @@ -296,7 +298,7 @@ export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
absoluteY > WINDOW_HEIGHT - animatedKeyboardHeight.value
)
) {
runOnJS(Keyboard.dismiss)();
dismissKeyboardOnJs();

This comment has been minimized.

Copy link
@LuisRego

LuisRego May 15, 2023

This will break if you are using reanimated > 3.x

const handleKeyboardDismiss = () => Keyboard.dismiss();

runOnJS(handleKeyboardDismiss)();

This comment has been minimized.

Copy link
@CarlMenke

CarlMenke May 16, 2023

do you have any idea what is the latest version of reanimated that wont break this?

This comment has been minimized.

Copy link
@FlashLim

FlashLim May 18, 2023

This will break if you are using reanimated > 3.x

const handleKeyboardDismiss = () => Keyboard.dismiss();

runOnJS(handleKeyboardDismiss)();

tested this, works fine for reanimated > 3.x

This comment has been minimized.

Copy link
@LuisRego

LuisRego Jun 2, 2023

do you have any idea what is the latest version of reanimated that wont break this?

I would say all the v2.x.x versions.

}
}

Expand Down

0 comments on commit 94cf11e

Please sign in to comment.