Skip to content
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

fix: Start Chat - Invalid red dot briefly appears by closing 'room' tab when there's no prior action #30679

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,15 @@ const CONST = {
*/
ADDITIONAL_ALLOWED_CHARACTERS: 20,

/**
* native IDs for close buttons in Overlay component
*/
OVERLAY: {
TOP_BUTTON_NATIVE_ID: 'overLayTopButton',
BOTTOM_BUTTON_NATIVE_ID: 'overLayBottomButton',
},

BACK_BUTTON_NATIVE_ID: 'backButton',
REFERRAL_PROGRAM: {
CONTENT_TYPES: {
MONEY_REQUEST: 'request',
Expand Down
10 changes: 10 additions & 0 deletions src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,17 @@ function Form(props) {
// We delay the validation in order to prevent Checkbox loss of focus when
// the user are focusing a TextInput and proceeds to toggle a CheckBox in
// web and mobile web platforms.

// Prevents React from resetting its properties
event.persist();
setTimeout(() => {
const relatedTargetId = lodashGet(event, 'nativeEvent.relatedTarget.id');
if (
relatedTargetId &&
_.includes([CONST.OVERLAY.BOTTOM_BUTTON_NATIVE_ID, CONST.OVERLAY.TOP_BUTTON_NATIVE_ID, CONST.BACK_BUTTON_NATIVE_ID], relatedTargetId)
) {
return;
}
setTouchedInput(inputID);
if (props.shouldValidateOnBlur) {
onValidate(inputValues, !hasServerError);
Expand Down
7 changes: 7 additions & 0 deletions src/components/Form/FormProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,14 @@ function FormProvider({validate, formID, shouldValidateOnBlur, shouldValidateOnC
// We delay the validation in order to prevent Checkbox loss of focus when
// the user is focusing a TextInput and proceeds to toggle a CheckBox in
// web and mobile web platforms.

// Prevents React from resetting its properties
event.persist();
Julesssss marked this conversation as resolved.
Show resolved Hide resolved
setTimeout(() => {
const relatedTargetId = lodashGet(event, 'nativeEvent.relatedTarget.id');
if (relatedTargetId && _.includes([CONST.OVERLAY.BOTTOM_BUTTON_NATIVE_ID, CONST.OVERLAY.TOP_BUTTON_NATIVE_ID, CONST.BACK_BUTTON_NATIVE_ID], relatedTargetId)) {
return;
}
setTouchedInput(inputID);
if (shouldValidateOnBlur) {
onValidate(inputValues, !hasServerError);
Expand Down
1 change: 1 addition & 0 deletions src/components/HeaderWithBackButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function HeaderWithBackButton({
style={[styles.touchableButtonImage]}
role="button"
accessibilityLabel={translate('common.back')}
nativeID={CONST.BACK_BUTTON_NATIVE_ID}
>
<Icon
src={Expensicons.BackArrow}
Expand Down
2 changes: 1 addition & 1 deletion src/components/RoomNameInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
onSelectionChange={(event) => setSelection(event.nativeEvent.selection)}
errorText={errorText}
autoCapitalize="none"
onBlur={() => isFocused && onBlur()}
onBlur={(event) => isFocused && onBlur(event)}
shouldDelayFocus={shouldDelayFocus}
autoFocus={isFocused && autoFocus}
maxLength={CONST.REPORT.MAX_ROOM_NAME_LENGTH}
Expand Down
2 changes: 1 addition & 1 deletion src/components/RoomNameInput/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
errorText={errorText}
maxLength={CONST.REPORT.MAX_ROOM_NAME_LENGTH}
keyboardType={keyboardType} // this is a bit hacky solution to a RN issue https://github.com/facebook/react-native/issues/27449
onBlur={() => isFocused && onBlur()}
onBlur={(event) => isFocused && onBlur(event)}
autoFocus={isFocused && autoFocus}
autoCapitalize="none"
shouldDelayFocus={shouldDelayFocus}
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/AppNavigator/Navigators/Overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ function Overlay(props) {
onPress={props.onPress}
accessibilityLabel={translate('common.close')}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
nativeID={CONST.OVERLAY.TOP_BUTTON_NATIVE_ID}
/>
<PressableWithoutFeedback
style={[styles.flex1]}
onPress={props.onPress}
accessibilityLabel={translate('common.close')}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
noDragArea
nativeID={CONST.OVERLAY.BOTTOM_BUTTON_NATIVE_ID}
/>
</View>
</Animated.View>
Expand Down
Loading