From 397bfa6ad7dff71f4b6d27ac17acc76fe8a6bbb5 Mon Sep 17 00:00:00 2001 From: Nadiia D Date: Tue, 2 Mar 2021 18:01:53 -0800 Subject: [PATCH] Hide caret during test runs Summary: Changelog: [General][Changed] Hide caret in the TextInput during test runs. Reviewed By: lunaleaps Differential Revision: D26728766 fbshipit-source-id: b75827f00b4d5c6243d93106093f97b40dc4b366 --- Libraries/Components/TextInput/TextInput.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 39967a67111..646e7d981a1 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -1083,6 +1083,13 @@ function InternalTextInput(props: Props): React.Node { ], ); + // Hide caret during test runs due to a flashing caret + // makes screenshot tests flakey + let caretHidden = props.caretHidden; + if (Platform.isTesting) { + caretHidden = true; + } + // TextInput handles onBlur and onFocus events // so omitting onBlur and onFocus pressability handlers here. const {onBlur, onFocus, ...eventHandlers} = usePressability(config) || {}; @@ -1105,6 +1112,7 @@ function InternalTextInput(props: Props): React.Node { {...eventHandlers} accessible={accessible} blurOnSubmit={blurOnSubmit} + caretHidden={caretHidden} dataDetectorTypes={props.dataDetectorTypes} focusable={focusable} mostRecentEventCount={mostRecentEventCount} @@ -1143,6 +1151,7 @@ function InternalTextInput(props: Props): React.Node { accessible={accessible} autoCapitalize={autoCapitalize} blurOnSubmit={blurOnSubmit} + caretHidden={caretHidden} children={children} disableFullscreenUI={props.disableFullscreenUI} focusable={focusable}