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
Original file line number Diff line number Diff line change
@@ -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).
*
Expand All @@ -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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch this to _.has() instead? As far as I can tell we don't use the in keyword in our codebase

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! FYI I took over this PR as Eugene is out of office. Using underscore is forbidden in TypeScript files, afaik we are using in in some places e.g. useDraggableInPortal.ts. Let me know what you think!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. On second look, it does look like we are starting to use in in typescript

const length = input.value.length;
input.setSelectionRange(length, length);
// eslint-disable-next-line no-param-reassign
Expand Down