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

Don't reset page title after a root-level error #10406

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 6 additions & 16 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { useAuth0 } from "@auth0/auth0-react";
import { Store } from "@reduxjs/toolkit";
import type { AppContext, AppProps } from "next/app";
import NextApp from "next/app";
import Head from "next/head";
import { useRouter } from "next/router";
import React, { ReactNode, memo, useEffect, useState } from "react";
import React, { ReactNode, useEffect, useState } from "react";
import { Provider } from "react-redux";
import "../src/global-css";
import "../src/test-prep";
Expand Down Expand Up @@ -85,9 +84,13 @@ function Routing({ Component, pageProps }: AppProps) {
return <MaintenanceModeScreen />;
}

// Don't set a default title in this component
// Else it overrides the recording title when the root error boundary renders
// See FE-2041
return (
<Provider store={store}>
<MemoizedHeader />
<meta httpEquiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" type="image/svg+xml" href="/images/favicon.svg" />
<RootErrorBoundary replayClient={replayClient}>
<_App>
<InstallRouteListener />
Expand All @@ -100,19 +103,6 @@ function Routing({ Component, pageProps }: AppProps) {
);
}

// Ensure this component only renders once even if the parent component re-renders
// Otherwise it can temporarily override titles set by child components,
// causing the document title to flicker.
const MemoizedHeader = memo(function MemoizedHeader() {
return (
<Head>
<meta httpEquiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" type="image/svg+xml" href="/images/favicon.svg" />
<title>Replay</title>
</Head>
);
});

const App = ({ apiKey, ...props }: AppProps & AuthProps) => {
useAuthTelemetry();
const router = useRouter();
Expand Down
7 changes: 7 additions & 0 deletions src/ui/components/Library/Library.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Head from "next/head";
import { useRouter } from "next/router";
import { useEffect } from "react";

Expand Down Expand Up @@ -63,6 +64,9 @@ export default function LibraryLoader() {
if (userSettingsLoading || userInfo.loading) {
return (
<div className="flex h-screen w-full items-center justify-center">
<Head>
<title>Replay</title>
</Head>
<LibrarySpinner />
</div>
);
Expand Down Expand Up @@ -100,6 +104,9 @@ function Library({ userSettings, userInfo }: { userSettings: UserSettings; userI

return (
<div className="flex h-screen w-screen flex-row">
<Head>
<title>Replay</title>
</Head>
<Navigation />
<InlineErrorBoundary key={teamId} name="Library">
<TeamPage />
Expand Down
Loading