From 1c9b514738037e81fcbc1b434191cab128eb64ed Mon Sep 17 00:00:00 2001
From: Olivier Tassinari <olivier.tassinari@gmail.com>
Date: Tue, 23 Aug 2022 12:03:07 +0200
Subject: [PATCH] [core] Fix scroll restoration (#34037)

---
 CHANGELOG.old.md                              |  2 +-
 docs/next.config.js                           | 19 +++++++++++++------
 .../blog/2019-developer-survey-results.md     |  2 +-
 docs/src/components/showcase/ThemeChip.tsx    |  2 +-
 docs/src/modules/components/ThemeContext.js   | 13 +------------
 5 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/CHANGELOG.old.md b/CHANGELOG.old.md
index fb0709af299f54..d9aba68795321b 100644
--- a/CHANGELOG.old.md
+++ b/CHANGELOG.old.md
@@ -13558,7 +13558,7 @@ _May 24, 2015_
 
 ### Breaking Changes
 
-- Refactored all CSS into Javascript (#30, #316)
+- Refactored all CSS into JavaScript (#30, #316)
   - All Material UI components now have their styles defined inline. This solves
     many problems with CSS as mentions in [@vjeux's presentation](https://speakerdeck.com/vjeux/react-css-in-js)
     such as polluting the global namespace with classes that really should be
diff --git a/docs/next.config.js b/docs/next.config.js
index 86ee793a5a8c9a..faf547e86cd89a 100644
--- a/docs/next.config.js
+++ b/docs/next.config.js
@@ -27,7 +27,10 @@ if (staging) {
   console.log(`Staging deploy of ${process.env.REPOSITORY_URL || 'local repository'}`);
 }
 
-module.exports = {
+const baseline = {
+  experimental: {
+    scrollRestoration: true,
+  },
   eslint: {
     ignoreDuringBuilds: true,
   },
@@ -35,6 +38,14 @@ module.exports = {
     // Motivated by https://github.com/vercel/next.js/issues/7687
     ignoreBuildErrors: true,
   },
+  trailingSlash: true,
+  // Can be turned on when https://github.com/vercel/next.js/issues/24640 is fixed
+  optimizeFonts: false,
+};
+
+module.exports = {
+  ...baseline,
+  baseline, // Exported so the other projects can use this configuration directly.
   webpack: (config, options) => {
     const plugins = config.plugins.slice();
 
@@ -179,7 +190,6 @@ module.exports = {
     NETLIFY_DEPLOY_URL: process.env.DEPLOY_URL || 'http://localhost:3000',
     NETLIFY_SITE_NAME: process.env.SITE_NAME || 'material-ui',
     PULL_REQUEST: process.env.PULL_REQUEST === 'true',
-    REACT_STRICT_MODE: reactStrictMode,
     FEEDBACK_URL: process.env.FEEDBACK_URL,
     // #default-branch-switch
     SOURCE_CODE_ROOT_URL: 'https://github.com/mui/material-ui/blob/master',
@@ -238,9 +248,8 @@ module.exports = {
     return map;
   },
   reactStrictMode,
-  trailingSlash: true,
   // rewrites has no effect when run `next export` for production
-  async rewrites() {
+  rewrites: async () => {
     return [
       { source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' },
       // Make sure to include the trailing slash if `trailingSlash` option is set
@@ -248,6 +257,4 @@ module.exports = {
       { source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' },
     ];
   },
-  // Can be turned on when https://github.com/vercel/next.js/issues/24640 is fixed
-  optimizeFonts: false,
 };
diff --git a/docs/pages/blog/2019-developer-survey-results.md b/docs/pages/blog/2019-developer-survey-results.md
index 20df950f656a3a..959e8b7c79747c 100644
--- a/docs/pages/blog/2019-developer-survey-results.md
+++ b/docs/pages/blog/2019-developer-survey-results.md
@@ -215,7 +215,7 @@ designers to give it a bespoke look and feel for their organization.
 
 <img src="/static/blog/2019-survey/9.png" style="display: block; margin: 0 auto;" alt="Bar chart: 26 x I'm just getting started!, 43 x 6 months +, 150 x 1 year +, 179 x 3 years +, 155 x 5 years, 82 x 10 years +, 47 x 15 years +" />
 
-A nice bell curve, with the majority of developers having 1 to 5 years experience with Javascript.
+A nice bell curve, with the majority of developers having 1 to 5 years experience with JavaScript.
 
 ### 10. How long have you been developing with React?
 
diff --git a/docs/src/components/showcase/ThemeChip.tsx b/docs/src/components/showcase/ThemeChip.tsx
index a01d62609192e6..a93792452d7732 100644
--- a/docs/src/components/showcase/ThemeChip.tsx
+++ b/docs/src/components/showcase/ThemeChip.tsx
@@ -89,7 +89,7 @@ export default function ThemeChip() {
     <ThemeProvider theme={theme}>
       <Stack direction="row" spacing={2}>
         <Chip label="React" color="primary" onDelete={() => {}} />
-        <Chip label="Javascript" onDelete={() => {}} />
+        <Chip label="JavaScript" onDelete={() => {}} />
       </Stack>
     </ThemeProvider>
   );
diff --git a/docs/src/modules/components/ThemeContext.js b/docs/src/modules/components/ThemeContext.js
index 56c8f56ab85a23..299582eb96a795 100644
--- a/docs/src/modules/components/ThemeContext.js
+++ b/docs/src/modules/components/ThemeContext.js
@@ -1,10 +1,6 @@
 import * as React from 'react';
 import PropTypes from 'prop-types';
-import {
-  ThemeProvider as MuiThemeProvider,
-  createTheme as createLegacyModeTheme,
-  unstable_createMuiStrictModeTheme as createStrictModeTheme,
-} from '@mui/material/styles';
+import { ThemeProvider as MuiThemeProvider, createTheme } from '@mui/material/styles';
 import { deepmerge } from '@mui/utils';
 import useMediaQuery from '@mui/material/useMediaQuery';
 import { enUS, zhCN, faIR, ruRU, ptBR, esES, frFR, deDE, jaJP } from '@mui/material/locale';
@@ -116,13 +112,6 @@ if (process.env.NODE_ENV !== 'production') {
   DispatchContext.displayName = 'ThemeDispatchContext';
 }
 
-let createTheme;
-if (process.env.REACT_STRICT_MODE) {
-  createTheme = createStrictModeTheme;
-} else {
-  createTheme = createLegacyModeTheme;
-}
-
 export function ThemeProvider(props) {
   const { children } = props;
   const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');