From 004fe5328d52704ce4bc29b0ffde65ea784312f5 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Tue, 29 Aug 2023 19:01:18 +0200 Subject: [PATCH] migrate focusAndUpdateMultilineInputRange to ts --- ...eInputRange.js => focusAndUpdateMultilineInputRange.ts} | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename src/libs/{focusAndUpdateMultilineInputRange.js => focusAndUpdateMultilineInputRange.ts} (81%) diff --git a/src/libs/focusAndUpdateMultilineInputRange.js b/src/libs/focusAndUpdateMultilineInputRange.ts similarity index 81% rename from src/libs/focusAndUpdateMultilineInputRange.js rename to src/libs/focusAndUpdateMultilineInputRange.ts index b5e438899d3d..50c3703239df 100644 --- a/src/libs/focusAndUpdateMultilineInputRange.js +++ b/src/libs/focusAndUpdateMultilineInputRange.ts @@ -1,3 +1,4 @@ +import {TextInput} from 'react-native'; /** * Focus a multiline text input and place the cursor at the end of the value (if there is a value in the input). * @@ -6,16 +7,14 @@ * focus. This provides a better user experience in cases where the text in the field has to be edited. The auto- * scroll behaviour works on all platforms except iOS native. * See https://github.com/Expensify/App/issues/20836 for more details. - * - * @param {Object} input the input element */ -export default function focusAndUpdateMultilineInputRange(input) { +export default function focusAndUpdateMultilineInputRange(input: TextInput | HTMLTextAreaElement) { if (!input) { return; } input.focus(); - if (input.value && input.setSelectionRange) { + if ('setSelectionRange' in input && input.value) { const length = input.value.length; input.setSelectionRange(length, length); // eslint-disable-next-line no-param-reassign