Skip to content

Commit

Permalink
Merge pull request #27321 from kubabutkiewicz/ts-migration/focus-with…
Browse files Browse the repository at this point in the history
…-delay-lib

[No QA] [TS Migration] Migrate 'focusWithDelay' lib to TypeScript
  • Loading branch information
marcochavezf authored Sep 20, 2023
2 parents 1340b27 + 3789cc3 commit 26081cc
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 26081cc

Please sign in to comment.