You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/libs/UnreadIndicatorUpdater/updateUnread/index.ts
+15-17Lines changed: 15 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -26,32 +26,30 @@ Onyx.connectWithoutView({
26
26
*/
27
27
functionsetPageTitle(title: string){
28
28
currentPageTitle=title;
29
-
// Immediately update the document title when page title changes
30
29
updateDocumentTitle();
31
30
}
32
31
33
32
/**
34
-
* Update the actual document title and favicon
33
+
* Synchronous on purpose. Deferring (setTimeout/queueMicrotask) loses a race with React Navigation's
34
+
* createMemoryHistory popstate handler, which captures and re-asserts document.title — re-applying
35
+
* the stale value if our write hasn't landed yet.
35
36
*/
36
37
functionupdateDocumentTitle(){
38
+
if(typeofdocument==='undefined'){
39
+
return;
40
+
}
37
41
consthasUnread=unreadTotalCount!==0;
38
-
// This setTimeout is required because due to how react rendering messes with the DOM, the document title can't be modified synchronously, and we must wait until all JS is done
39
-
// running before setting the title.
40
-
setTimeout(()=>{
41
-
// There is a Chrome browser bug that causes the title to revert back to the previous when we are navigating back. Setting the title to an empty string
42
-
// seems to improve this issue.
43
-
document.title='';
44
42
45
-
// Use page-specific title if available, otherwise use the default SITE_TITLE
0 commit comments