Skip to content

Commit 0a74e5c

Browse files
committed
fix: replace animated header with non-animated header in placeholders to resolve suspense bug (#12844)
* fix: replace animated header with non-animated header in placeholders to resolve suspense bug * hide second header in placeholders
1 parent 87edd75 commit 0a74e5c

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

src/app/Components/Cards/CardWithMetaData.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ export const CardsWithMetaDataListPlaceholder: React.FC<CardsWithMetaDataListPla
121121

122122
return (
123123
<Screen>
124-
<Screen.AnimatedHeader onBack={goBack} title={title} />
124+
{/* IMPORTANT: use a non animated header inside placeholders due to a bug that never
125+
lets suspense resolve when used with an animated header and resulting on a blank screen. */}
126+
<Screen.Header onBack={goBack} title="" />
125127
<Screen.Body fullwidth>
126128
<ProvidePlaceholderContext>
127129
<Flex testID={testID} flexDirection="column" justifyContent="space-between" height="100%">

src/app/Scenes/MyProfile/Components/MyProfileScreenWrapper.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,49 @@ export const MyProfileScreenWrapper: React.FC<
5757
</Screen>
5858
)
5959
}
60+
61+
/* IMPORTANT: use a non animated header inside placeholders due to a bug that never
62+
lets suspense resolve when used with an animated header and resulting on a blank screen. */
63+
export const MyProfileScreenWrapperPlaceholder: React.FC<
64+
React.PropsWithChildren<MyProfileScreenWrapperProps>
65+
> = ({
66+
children,
67+
title,
68+
onPress,
69+
hideLeftElements = false,
70+
contentContainerStyle,
71+
RefreshControl,
72+
}) => {
73+
const space = useSpace()
74+
75+
return (
76+
<Screen>
77+
<Screen.Header title="" hideLeftElements={hideLeftElements} onBack={goBack} />
78+
<Screen.StickySubHeader title={title} />
79+
<Screen.Body fullwidth>
80+
<Screen.ScrollView
81+
keyboardShouldPersistTaps="handled"
82+
keyboardDismissMode="on-drag"
83+
contentContainerStyle={{
84+
paddingTop: space(2),
85+
paddingHorizontal: space(2),
86+
// This is required to make room for the save button on top of the bottom tabs
87+
// Screen.ScrollView doesn't consider the save button in its height calculation
88+
paddingBottom: SCROLLVIEW_PADDING_BOTTOM_OFFSET,
89+
...contentContainerStyle,
90+
}}
91+
refreshControl={RefreshControl}
92+
>
93+
{children}
94+
{!!onPress && (
95+
<Flex my={2}>
96+
<Button block onPress={onPress} disabled loading>
97+
Save
98+
</Button>
99+
</Flex>
100+
)}
101+
</Screen.ScrollView>
102+
</Screen.Body>
103+
</Screen>
104+
)
105+
}

src/app/Scenes/MyProfile/MyProfilePushNotifications.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import {
88
import { LoadFailureView } from "app/Components/LoadFailureView"
99
import { SwitchMenu } from "app/Components/SwitchMenu"
1010
import { updateMyUserProfile } from "app/Scenes/MyAccount/updateMyUserProfile"
11-
import { MyProfileScreenWrapper } from "app/Scenes/MyProfile/Components/MyProfileScreenWrapper"
11+
import {
12+
MyProfileScreenWrapper,
13+
MyProfileScreenWrapperPlaceholder,
14+
} from "app/Scenes/MyProfile/Components/MyProfileScreenWrapper"
1215
import {
1316
getNotificationPermissionsStatus,
1417
PushAuthorizationStatus,
@@ -157,7 +160,10 @@ const NotificationPermissionsBox = ({
157160

158161
const MyProfilePushNotificationsPlaceholder: React.FC<{}> = () => {
159162
return (
160-
<MyProfileScreenWrapper title="Notifications" contentContainerStyle={{ paddingHorizontal: 0 }}>
163+
<MyProfileScreenWrapperPlaceholder
164+
title="Notifications"
165+
contentContainerStyle={{ paddingHorizontal: 0 }}
166+
>
161167
<Flex>
162168
<Content
163169
userNotificationSettings={
@@ -179,7 +185,7 @@ const MyProfilePushNotificationsPlaceholder: React.FC<{}> = () => {
179185
notificationAuthorizationStatus={PushAuthorizationStatus.NotDetermined}
180186
/>
181187
</Flex>
182-
</MyProfileScreenWrapper>
188+
</MyProfileScreenWrapperPlaceholder>
183189
)
184190
}
185191

0 commit comments

Comments
 (0)