Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] [TS Migration] Migrate 'focusWithDelay' lib to TypeScript #27321

Merged
Merged
Changes from 3 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 FocusWithDelayReturn = (shouldDelay?: boolean) => void;
/**
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
* 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): FocusWithDelayReturn {
/**
* Focus the text input
* @param {Boolean} [shouldDelay=false] Impose delay before focusing the text input
* Impose delay before focusing the text input
*/
kubabutkiewicz marked this conversation as resolved.
Show resolved Hide resolved
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
Loading