Skip to content

fix: close keyboard before scroll when editing message #59645

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

Merged
merged 2 commits into from
Apr 15, 2025
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
6 changes: 3 additions & 3 deletions src/pages/home/report/ReportActionItemMessageEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import lodashDebounce from 'lodash/debounce';
import type {ForwardedRef} from 'react';
import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {findNodeHandle, InteractionManager, Keyboard, View} from 'react-native';
import {findNodeHandle, InteractionManager, View} from 'react-native';
import type {MeasureInWindowOnSuccessCallback, NativeSyntheticEvent, TextInput, TextInputFocusEventData, TextInputKeyPressEventData, TextInputScrollEventData} from 'react-native';
import {useFocusedInputHandler} from 'react-native-keyboard-controller';
import {useOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -45,6 +45,7 @@ import setShouldShowComposeInputKeyboardAware from '@libs/setShouldShowComposeIn
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import KeyboardUtils from '@src/utils/keyboard';
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
import getCursorPosition from './ReportActionCompose/getCursorPosition';
import getScrollPosition from './ReportActionCompose/getScrollPosition';
Expand Down Expand Up @@ -255,9 +256,8 @@ function ReportActionItemMessageEdit(

// Scroll to the last comment after editing to make sure the whole comment is clearly visible in the report.
if (index === 0) {
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
KeyboardUtils.dismiss().then(() => {
reportScrollManager.scrollToIndex(index, false);
keyboardDidHideListener.remove();
});
}
}, [action, index, reportID, reportScrollManager, isActive]);
Expand Down