Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libs/focusWithDelay.js → src/libs/focusWithDelay.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {InteractionManager} from 'react-native';
import {InteractionManager, TextInput} from 'react-native';
import ComposerFocusManager from './ComposerFocusManager';

type FocusWithDelay = (shouldDelay?: boolean) => void;
/**
* Create a function that focuses a text input.
* @param {Object} textInput the text input to focus
* @returns {Function} a function that focuses the text input with a configurable delay
*/
function focusWithDelay(textInput) {
function focusWithDelay(textInput: TextInput | null): FocusWithDelay {
/**
* Focus the text input
* @param {Boolean} [shouldDelay=false] Impose delay before focusing the text input
* @param [shouldDelay] Impose delay before focusing the text input
*/
return (shouldDelay = false) => {
// There could be other animations running while we trigger manual focus.
Expand All @@ -18,6 +17,7 @@ function focusWithDelay(textInput) {
if (!textInput) {
return;
}

if (!shouldDelay) {
textInput.focus();
return;
Expand Down