Skip to content
Closed
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
1 change: 1 addition & 0 deletions src/hooks/useDocumentTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function useDocumentTitle(title: string) {
useFocusEffect(
useCallback(() => {
setPageTitle(title);
return () => setPageTitle('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Don't reset the global tab title in the focus cleanup

In our React Navigation 7 setup, the function returned from useFocusEffect is an effect cleanup, not a blur-only handler. Calling setPageTitle('') here mutates the shared currentPageTitle in src/libs/UnreadIndicatorUpdater/updateUnread/index.ts, so when the user switches between two screens that both use useDocumentTitle (for example HomePage, SearchPage, or ReportScreen), the outgoing screen can clear the title after the incoming screen has already focused. Because the document title is applied asynchronously in updateDocumentTitle(), this leaves the browser tab stuck on CONFIG.SITE_TITLE/New Expensify instead of the new page title, reintroducing the split-pane title race this hook just stopped having.

Useful? React with 👍 / 👎.

}, [title]),
);
}
Expand Down
Loading