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 'focusTextInputAfterAnimation' lib to TypeScript #26180

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import FocusTextInputAfterAnimation from './types';

/**
* Focus the text input with a slight delay to make sure modals are closed first.
* Since in react-native-modal `onModalHide` is called before the modal is actually hidden.
* It results in the keyboard being dismissed right away on both iOS and Android.
* See this discussion for more details: https://github.com/Expensify/App/issues/18300
*
* @param {Object} inputRef
* @param {Number} animationLength you must use your best guess as to what a good animationLength is. It can't be too short, or the animation won't be finished. It can't be too long or
* @param animationLength you must use your best guess as to what a good animationLength is. It can't be too short, or the animation won't be finished. It can't be too long or
* the user will notice that it feels sluggish
*/
const focusTextInputAfterAnimation = (inputRef, animationLength = 0) => {
const focusTextInputAfterAnimation: FocusTextInputAfterAnimation = (inputRef, animationLength = 0) => {
setTimeout(() => {
inputRef.focus();
}, animationLength);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import FocusTextInputAfterAnimation from './types';

/**
* This library is a no-op for all platforms except for Android and iOS and will immediately focus the given input without any delays.
*
* @param {Object} inputRef
*/
const focusTextInputAfterAnimation = (inputRef) => {
const focusTextInputAfterAnimation: FocusTextInputAfterAnimation = (inputRef) => {
inputRef.focus();
};

Expand Down
5 changes: 5 additions & 0 deletions src/libs/focusTextInputAfterAnimation/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {TextInput} from 'react-native';

type FocusTextInputAfterAnimation = (inputRef: TextInput | HTMLInputElement, animationLength: number) => void;

export default FocusTextInputAfterAnimation;
BartoszGrajdek marked this conversation as resolved.
Show resolved Hide resolved