Skip to content

Commit 9cfe182

Browse files
authored
Merge pull request #30679 from dukenv0307/fix/30618
fix: Start Chat - Invalid red dot briefly appears by closing 'room' tab when there's no prior action
2 parents 222993c + 4d112cf commit 9cfe182

File tree

7 files changed

+31
-2
lines changed

7 files changed

+31
-2
lines changed

src/CONST.ts

+9
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,15 @@ const CONST = {
28802880
*/
28812881
ADDITIONAL_ALLOWED_CHARACTERS: 20,
28822882

2883+
/**
2884+
* native IDs for close buttons in Overlay component
2885+
*/
2886+
OVERLAY: {
2887+
TOP_BUTTON_NATIVE_ID: 'overLayTopButton',
2888+
BOTTOM_BUTTON_NATIVE_ID: 'overLayBottomButton',
2889+
},
2890+
2891+
BACK_BUTTON_NATIVE_ID: 'backButton',
28832892
REFERRAL_PROGRAM: {
28842893
CONTENT_TYPES: {
28852894
MONEY_REQUEST: 'request',

src/components/Form.js

+10
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,17 @@ function Form(props) {
351351
// We delay the validation in order to prevent Checkbox loss of focus when
352352
// the user are focusing a TextInput and proceeds to toggle a CheckBox in
353353
// web and mobile web platforms.
354+
355+
// Prevents React from resetting its properties
356+
event.persist();
354357
setTimeout(() => {
358+
const relatedTargetId = lodashGet(event, 'nativeEvent.relatedTarget.id');
359+
if (
360+
relatedTargetId &&
361+
_.includes([CONST.OVERLAY.BOTTOM_BUTTON_NATIVE_ID, CONST.OVERLAY.TOP_BUTTON_NATIVE_ID, CONST.BACK_BUTTON_NATIVE_ID], relatedTargetId)
362+
) {
363+
return;
364+
}
355365
setTouchedInput(inputID);
356366
if (props.shouldValidateOnBlur) {
357367
onValidate(inputValues, !hasServerError);

src/components/Form/FormProvider.js

+7
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,14 @@ function FormProvider({validate, formID, shouldValidateOnBlur, shouldValidateOnC
266266
// We delay the validation in order to prevent Checkbox loss of focus when
267267
// the user is focusing a TextInput and proceeds to toggle a CheckBox in
268268
// web and mobile web platforms.
269+
270+
// Prevents React from resetting its properties
271+
event.persist();
269272
setTimeout(() => {
273+
const relatedTargetId = lodashGet(event, 'nativeEvent.relatedTarget.id');
274+
if (relatedTargetId && _.includes([CONST.OVERLAY.BOTTOM_BUTTON_NATIVE_ID, CONST.OVERLAY.TOP_BUTTON_NATIVE_ID, CONST.BACK_BUTTON_NATIVE_ID], relatedTargetId)) {
275+
return;
276+
}
270277
setTouchedInput(inputID);
271278
if (shouldValidateOnBlur) {
272279
onValidate(inputValues, !hasServerError);

src/components/HeaderWithBackButton/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function HeaderWithBackButton({
7979
style={[styles.touchableButtonImage]}
8080
role="button"
8181
accessibilityLabel={translate('common.back')}
82+
nativeID={CONST.BACK_BUTTON_NATIVE_ID}
8283
>
8384
<Icon
8485
src={Expensicons.BackArrow}

src/components/RoomNameInput/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
5757
onSelectionChange={(event) => setSelection(event.nativeEvent.selection)}
5858
errorText={errorText}
5959
autoCapitalize="none"
60-
onBlur={() => isFocused && onBlur()}
60+
onBlur={(event) => isFocused && onBlur(event)}
6161
shouldDelayFocus={shouldDelayFocus}
6262
autoFocus={isFocused && autoFocus}
6363
maxLength={CONST.REPORT.MAX_ROOM_NAME_LENGTH}

src/components/RoomNameInput/index.native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
4141
errorText={errorText}
4242
maxLength={CONST.REPORT.MAX_ROOM_NAME_LENGTH}
4343
keyboardType={keyboardType} // this is a bit hacky solution to a RN issue https://github.com/facebook/react-native/issues/27449
44-
onBlur={() => isFocused && onBlur()}
44+
onBlur={(event) => isFocused && onBlur(event)}
4545
autoFocus={isFocused && autoFocus}
4646
autoCapitalize="none"
4747
shouldDelayFocus={shouldDelayFocus}

src/libs/Navigation/AppNavigator/Navigators/Overlay.js

+2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ function Overlay(props) {
2929
onPress={props.onPress}
3030
accessibilityLabel={translate('common.close')}
3131
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
32+
nativeID={CONST.OVERLAY.TOP_BUTTON_NATIVE_ID}
3233
/>
3334
<PressableWithoutFeedback
3435
style={[styles.flex1]}
3536
onPress={props.onPress}
3637
accessibilityLabel={translate('common.close')}
3738
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
3839
noDragArea
40+
nativeID={CONST.OVERLAY.BOTTOM_BUTTON_NATIVE_ID}
3941
/>
4042
</View>
4143
</Animated.View>

0 commit comments

Comments
 (0)