Skip to content

Commit 85d08e1

Browse files
Fix ParentView keyboard dismiss on New Architecture (#703)
1 parent 312d15f commit 85d08e1

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/components/ParentView.jsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from "react";
2-
import { Keyboard, StatusBar } from "react-native";
2+
import { Keyboard, StatusBar, TextInput } from "react-native";
33

44
import PropTypes from "prop-types";
55
import {
@@ -10,8 +10,6 @@ import { ThemeContext } from "styled-components/native";
1010

1111
import { Container } from "./Container";
1212

13-
import { useKeyboard } from "../hooks/useKeyboard";
14-
1513
/**
1614
*ParentView wraps the children with SafeAreaView.
1715
*
@@ -45,7 +43,6 @@ export const ParentView = ({
4543
...rest
4644
}) => {
4745
const theme = useContext(ThemeContext);
48-
const keyboardHeight = useKeyboard();
4946

5047
const safeAreaViewProps = {
5148
edges: [
@@ -80,12 +77,11 @@ export const ParentView = ({
8077
{...(shouldDismissKeyboardOnTap
8178
? {
8279
onTouchStart: e => {
83-
if (
84-
keyboardHeight &&
85-
e?.target?._internalFiberInstanceHandleDEV?.elementType?.indexOf(
86-
"TextInput"
87-
) === -1
88-
) {
80+
// TextInput.State is the only architecture-agnostic way to
81+
// know a tap landed outside the focused input — Fabric event
82+
// targets don't carry the Paper fiber internals.
83+
const focusedInput = TextInput.State.currentlyFocusedInput();
84+
if (focusedInput && e.target !== focusedInput) {
8985
Keyboard.dismiss();
9086
}
9187
},

0 commit comments

Comments
 (0)