Skip to content

Commit ba6c86f

Browse files
Fix zombie SPAN_NAVIGATE_TO_INBOX_TAB spans on Inbox tab re-visits
1 parent 337f2a5 commit ba6c86f

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/pages/inbox/sidebar/SidebarLinksData.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ function SidebarLinksData({insets}: SidebarLinksDataProps) {
3030
currentReportIDRef.current = currentReportID;
3131
const isActiveReport = useCallback((reportID: string): boolean => currentReportIDRef.current === reportID, []);
3232

33-
// IMPORTANT: Always end the telemetry navigation span for the Inbox tab when the screen gains focus.
34-
// This must handle both the initial mount and all subsequent Inbox tab visits,
35-
// as onLayout does not fire when navigating back to an already-mounted screen.
33+
// Guards against ending the span before the first layout has completed.
34+
const hasHadFirstLayout = useRef(false);
35+
const onLayout = useCallback(() => {
36+
hasHadFirstLayout.current = true;
37+
endSpan(CONST.TELEMETRY.SPAN_NAVIGATE_TO_INBOX_TAB);
38+
}, []);
39+
40+
// On re-visits, react-freeze serves the cached layout — onLayout never fires.
41+
// useFocusEffect fires on unfreeze, which is when the screen becomes visible.
3642
useFocusEffect(
3743
useCallback(() => {
44+
if (!hasHadFirstLayout.current) {
45+
return;
46+
}
3847
endSpan(CONST.TELEMETRY.SPAN_NAVIGATE_TO_INBOX_TAB);
3948
}, []),
4049
);
@@ -45,6 +54,7 @@ function SidebarLinksData({insets}: SidebarLinksDataProps) {
4554
collapsable={false}
4655
accessibilityLabel={translate('sidebarScreen.listOfChats')}
4756
style={[styles.flex1, styles.h100]}
57+
onLayout={onLayout}
4858
>
4959
<SidebarLinks
5060
// Forwarded props:

0 commit comments

Comments
 (0)