Skip to content

KeyboardController.dismiss doesn't work if the keyboard is still in motion #1400

@PrimulaX

Description

@PrimulaX

Describe the bug
I try to use dismiss functionality from lib and sometimes it works, I would say with a delay, basically if you call dismiss while keyboard animation is in progress (I think that because if I wait a little bit it works as expected) it ignores the dismiss but on the other hand dismiss from React Native closes keyboard right away.

Code snippet

import { useRef } from "react";
import { BottomSheetBackdrop, BottomSheetModal, BottomSheetView } from "@gorhom/bottom-sheet";
import { TextInput, Keyboard, View, Button, Text, StyleSheet } from "react-native";
import { KeyboardController } from "react-native-keyboard-controller";

export const TestComponent = () => {
	const inputRef = useRef<TextInput>(null);
	const ref = useRef<BottomSheetModal>(null);

	const openSheetWithRNDismiss = () => {
		Keyboard.dismiss();
		ref.current?.present();
	};

	const openSheetWithRNKCDismiss = () => {
		KeyboardController.dismiss();
		ref.current?.present();
	};

	const onDismiss = () => {
		inputRef.current?.focus();
	};

	return (
		<View style={styles.screenContainer}>
			<Button title="dismiss with rn" onPress={openSheetWithRNDismiss} />
			<TextInput placeholder="text input" ref={inputRef} />
			<Button title="dismiss with rnkc" onPress={openSheetWithRNKCDismiss} />
			<BottomSheetModal
				backdropComponent={BottomSheetBackdrop}
				ref={ref}
				snapPoints={["45%", "85%"]}
				index={1}
				onDismiss={onDismiss}
			>
				<BottomSheetView>
					<Text>This is content</Text>
				</BottomSheetView>
			</BottomSheetModal>
		</View>
	);
};

const styles = StyleSheet.create({
	screenContainer: {
		flex: 1,
		flexDirection: "column",
	},
});

To Reproduce
Steps to reproduce the behavior:

  1. Focus text input
  2. Press on "dismiss with rnkc" button
  3. Press on the backdrop to close the bottom sheet, and when the keyboard starts to show up, press the button again.
  4. See error

Expected behavior
Dismiss action should close the keyboard at any moment.

Screenshots

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-03-26.at.14.22.14.mp4

Smartphone (please complete the following information):

  • Desktop OS: macOS 26.3.1
  • Device: iPhone 17 Pro Simulator
  • OS: 26.2
  • RN version: 0.83.4
  • RN architecture: New Arch
  • JS engine: Hermes
  • Library version: 1.21.2

Metadata

Metadata

Assignees

Labels

repro providedIssue contains reproduction repository/code🐛 bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions