diff --git a/client/src/document/index.tsx b/client/src/document/index.tsx index de29c0e0288a..87ef45d767d5 100644 --- a/client/src/document/index.tsx +++ b/client/src/document/index.tsx @@ -84,6 +84,20 @@ export function Document(props /* TODO: define a TS interface for this */) { } }, [doc, error]); + React.useEffect(() => { + const location = document.location; + // Did you arrive on this page with a location hash? + if (location.hash && location.hash !== location.hash.toLowerCase()) { + // The location hash isn't lowercase. That probably means it's from before + // we made all `

` and `

` values always lowercase. + // Let's see if it can easily be fixed, but let's be careful and + // only do this if there is an element that matches. + if (document.querySelector(location.hash.toLowerCase())) { + location.hash = location.hash.toLowerCase(); + } + } + }, []); + if (!doc && !error) { return ; } diff --git a/client/src/document/ingredients/utils.tsx b/client/src/document/ingredients/utils.tsx index 9d4f4803f6ad..1003f2026bb8 100644 --- a/client/src/document/ingredients/utils.tsx +++ b/client/src/document/ingredients/utils.tsx @@ -1,6 +1,6 @@ export function DisplayH2({ id, title }: { id: string; title: string }) { return ( -

+

); @@ -8,7 +8,7 @@ export function DisplayH2({ id, title }: { id: string; title: string }) { export function DisplayH3({ id, title }: { id: string; title: string }) { return ( -

+

); @@ -16,7 +16,7 @@ export function DisplayH3({ id, title }: { id: string; title: string }) { function Permalink({ id, title }: { id: string; title: string }) { return ( - + {title} ); diff --git a/client/src/document/organisms/toc/index.tsx b/client/src/document/organisms/toc/index.tsx index b243cf754b73..9527350b6a0c 100644 --- a/client/src/document/organisms/toc/index.tsx +++ b/client/src/document/organisms/toc/index.tsx @@ -47,7 +47,7 @@ export function TOC({ toc }: { toc: Toc[] }) { diff --git a/testing/tests/headless.test.js b/testing/tests/headless.test.js index c5adec7db2ba..574e04631e5a 100644 --- a/testing/tests/headless.test.js +++ b/testing/tests/headless.test.js @@ -61,7 +61,7 @@ describe("Basic viewing of functional pages", () => { await expect(page).toMatchElement("h1", { text: "A Test Introduction to CSS layout", }); - await expect(page).toMatchElement("#Flexbox", { + await expect(page).toMatchElement("#flexbox", { text: "Flexbox", }); await expect(page).toMatchElement( @@ -70,7 +70,7 @@ describe("Basic viewing of functional pages", () => { await expect(page).toMatchElement( `iframe.live-sample-frame.sample-code-frame[src$="${flexSample2Uri}"]` ); - await expect(page).toMatchElement("#Grid_Layout", { + await expect(page).toMatchElement("#grid_layout", { text: "Grid Layout", }); await expect(page).toMatchElement( @@ -111,7 +111,7 @@ describe("Basic viewing of functional pages", () => { await expect(page).toMatchElement("h1", { text: "A Test Introduction to CSS Flexbox Layout", }); - await expect(page).toMatchElement("#Flexbox", { + await expect(page).toMatchElement("#flexbox", { text: "Flexbox", }); await expect(page).toMatchElement("#Flex_1 > pre.css.notranslate", { @@ -137,7 +137,7 @@ describe("Basic viewing of functional pages", () => { await expect(page).toMatchElement("h1", { text: "A Test Introduction to CSS Grid Layout", }); - await expect(page).toMatchElement("#Grid_Layout", { + await expect(page).toMatchElement("#grid_layout", { text: "Grid Layout", }); await expect(page).toMatchElement("#Grid_1 > pre.css.notranslate", {