Skip to content

Commit c1ceada

Browse files
authored
Revert "Composer: add clear command that bypasses the event count"
1 parent c5acf35 commit c1ceada

File tree

3 files changed

+4
-27
lines changed

3 files changed

+4
-27
lines changed
+1-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
import type {Component} from 'react';
2-
import type {AnimatedRef} from 'react-native-reanimated';
3-
import {dispatchCommand} from 'react-native-reanimated';
41
import type {AccessibilityRoleForm, NewPasswordAutocompleteType, PasswordAutocompleteType} from './types';
52

63
const PASSWORD_AUTOCOMPLETE_TYPE: PasswordAutocompleteType = 'password';
74
const NEW_PASSWORD_AUTOCOMPLETE_TYPE: NewPasswordAutocompleteType = 'password-new';
85
const ACCESSIBILITY_ROLE_FORM: AccessibilityRoleForm = 'none';
96

10-
/**
11-
* Clears a text input on the UI thread using a custom clear command
12-
* that bypasses the event count check.
13-
*/
14-
function forceClearInput(animatedInputRef: AnimatedRef<Component>) {
15-
'worklet';
16-
17-
dispatchCommand(animatedInputRef, 'clear');
18-
}
19-
20-
export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput};
7+
export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE};

src/libs/ComponentUtils/index.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import type {Component} from 'react';
2-
import type {AnimatedRef} from 'react-native-reanimated';
3-
import {setNativeProps} from 'react-native-reanimated';
41
import type {AccessibilityRoleForm, NewPasswordAutocompleteType, PasswordAutocompleteType} from './types';
52

63
/**
@@ -10,10 +7,4 @@ const PASSWORD_AUTOCOMPLETE_TYPE: PasswordAutocompleteType = 'current-password';
107
const NEW_PASSWORD_AUTOCOMPLETE_TYPE: NewPasswordAutocompleteType = 'new-password';
118
const ACCESSIBILITY_ROLE_FORM: AccessibilityRoleForm = 'form';
129

13-
function forceClearInput(animatedInputRef: AnimatedRef<Component>) {
14-
'worklet';
15-
16-
setNativeProps(animatedInputRef, {text: ''});
17-
}
18-
19-
export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput};
10+
export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE};

src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {MeasureInWindowOnSuccessCallback, NativeSyntheticEvent, TextInputFo
44
import {View} from 'react-native';
55
import type {OnyxEntry} from 'react-native-onyx';
66
import {withOnyx} from 'react-native-onyx';
7-
import {runOnJS, useAnimatedRef} from 'react-native-reanimated';
7+
import {runOnJS, setNativeProps, useAnimatedRef} from 'react-native-reanimated';
88
import type {Emoji} from '@assets/emojis/types';
99
import type {FileObject} from '@components/AttachmentModal';
1010
import AttachmentModal from '@components/AttachmentModal';
@@ -23,7 +23,6 @@ import useNetwork from '@hooks/useNetwork';
2323
import useThemeStyles from '@hooks/useThemeStyles';
2424
import useWindowDimensions from '@hooks/useWindowDimensions';
2525
import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus';
26-
import {forceClearInput} from '@libs/ComponentUtils';
2726
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
2827
import {getDraftComment} from '@libs/DraftCommentUtils';
2928
import getModalState from '@libs/getModalState';
@@ -367,7 +366,7 @@ function ReportActionCompose({
367366
// We are setting the isCommentEmpty flag to true so the status of it will be in sync of the native text input state
368367
runOnJS(setIsCommentEmpty)(true);
369368
runOnJS(resetFullComposerSize)();
370-
forceClearInput(animatedRef);
369+
setNativeProps(animatedRef, {text: ''}); // clears native text input on the UI thread
371370
runOnJS(submitForm)();
372371
}, [isSendDisabled, resetFullComposerSize, submitForm, animatedRef, isReportReadyForDisplay]);
373372

0 commit comments

Comments
 (0)