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

fix(core): revert wrong anchor link implementation change #10311

Merged
merged 11 commits into from
Jul 19, 2024

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jul 18, 2024

Motivation

Revert anchor link change from #9859

Anchors should use regular <a> tag and not React Router links, like it used to be. Using React Router would "resolve" the anchors and add a /pathname#anchor instead of just #anchor.

I don't remember why I did that change in the first place. It is not wrong but produces unwanted bugs in community packages (see gabrielcsapo/docusaurus-plugin-search-local#82 (comment))


Edit: I remember now why I made the chang. The new v3.4 hash router can't use a regular <a href="#anchor"> tag because the target page is not #anchor but /#/pathname#anchor: we need to use React Router link in this case.

However, I still think it's useful to revert partially this change for the "browser" router because anchor links will be simpler, closer to what the <Link> user provided as props, and produce a smaller HTML output.

Took the opportunity to write some basic unit tests because our link component is quite fragile and uncovered.

Test Plan

CI + preview + check hash routing deployment anchors still work

Test links

Deploy preview: https://deploy-preview-10311--docusaurus-2.netlify.app/

Hash Router artifacts: https://github.com/facebook/docusaurus/actions/workflows/build-hash-router.yml?query=branch%3Aslorber%2Frevert-anchor-link-impl-change

Related issues/PRs

fix #10307

gabrielcsapo/docusaurus-plugin-search-local#82 (comment)

@slorber slorber requested a review from Josh-Cena as a code owner July 18, 2024 13:50
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 18, 2024
@slorber slorber added pr: bug fix This PR fixes a bug in a past release. and removed CLA Signed Signed Facebook CLA labels Jul 18, 2024
Copy link

netlify bot commented Jul 18, 2024

[V2]

Name Link
🔨 Latest commit 17660b4
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/669a7ef957478b00089967f5
😎 Deploy Preview https://deploy-preview-10311--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 18, 2024
Copy link

github-actions bot commented Jul 18, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 73 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 73 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 68 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 48 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 70 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟠 86 Report

Copy link

github-actions bot commented Jul 18, 2024

Size Change: -58.8 kB (-0.54%)

Total Size: 10.9 MB

Filename Size Change
website/build/assets/js/main.********.js 668 kB +45 B (+0.01%)
website/build/blog/2017/12/14/introducing-docusaurus.html 74.8 kB -505 B (-0.67%)
website/build/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html 47.2 kB -365 B (-0.77%)
website/build/blog/2018/09/11/Towards-Docusaurus-2.html 51.5 kB -1.06 kB (-2.02%)
website/build/blog/2018/12/14/Happy-First-Birthday-Slash.html 33.2 kB -43 B (-0.13%)
website/build/blog/2019/12/30/docusaurus-2019-recap.html 39.6 kB -494 B (-1.23%)
website/build/blog/2020/01/07/tribute-to-endi.html 34 kB -32 B (-0.09%)
website/build/blog/2021/01/19/docusaurus-2020-recap.html 48.9 kB -570 B (-1.15%)
website/build/blog/2021/03/09/releasing-docusaurus-i18n.html 45.1 kB -630 B (-1.38%)
website/build/blog/2021/05/12/announcing-docusaurus-two-beta.html 52 kB -611 B (-1.16%)
website/build/blog/2021/11/21/algolia-docsearch-migration.html 52.9 kB -1.09 kB (-2.01%)
website/build/blog/2022/01/24/docusaurus-2021-recap.html 44.4 kB -570 B (-1.27%)
website/build/blog/2022/08/01/announcing-docusaurus-2.0.html 142 kB -1.18 kB (-0.82%)
website/build/blog/2022/09/01/docusaurus-2.1.html 50.8 kB -403 B (-0.79%)
website/build/blog/archive.html 24.6 kB -116 B (-0.47%)
website/build/blog/preparing-your-site-for-docusaurus-v3.html 138 kB -1.76 kB (-1.26%)
website/build/blog/releases/2.2.html 49.6 kB -269 B (-0.54%)
website/build/blog/releases/2.3.html 60.8 kB -269 B (-0.44%)
website/build/blog/releases/2.4.html 65.3 kB -305 B (-0.47%)
website/build/blog/releases/3.0.html 111 kB -527 B (-0.47%)
website/build/blog/releases/3.1.html 52 kB -160 B (-0.31%)
website/build/blog/releases/3.2.html 48.7 kB -269 B (-0.55%)
website/build/blog/releases/3.3.html 55.5 kB -197 B (-0.35%)
website/build/blog/releases/3.4.html 55.6 kB -190 B (-0.34%)
website/build/blog/tags.html 28.4 kB -119 B (-0.42%)
website/build/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing.html 128 kB -2.46 kB (-1.89%)
website/build/docs.html 49.4 kB -145 B (-0.29%)
website/build/docs/advanced/client.html 76 kB -146 B (-0.19%)
website/build/docs/advanced/plugins.html 58.6 kB -241 B (-0.41%)
website/build/docs/advanced/routing.html 73.9 kB -365 B (-0.49%)
website/build/docs/advanced/ssg.html 81.5 kB -251 B (-0.31%)
website/build/docs/api/docusaurus-config.html 200 kB -1.97 kB (-0.98%)
website/build/docs/api/misc/@docusaurus/eslint-plugin.html 48.3 kB -635 B (-1.3%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-html-links.html 38.1 kB -269 B (-0.7%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text.html 37 kB -548 B (-1.46%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading.html 38.3 kB -193 B (-0.5%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages.html 41.9 kB -482 B (-1.14%)
website/build/docs/api/misc/@docusaurus/logger.html 39.8 kB -164 B (-0.41%)
website/build/docs/api/misc/create-docusaurus.html 34.9 kB -415 B (-1.18%)
website/build/docs/api/plugin-methods.html 67.4 kB -259 B (-0.38%)
website/build/docs/api/plugin-methods/extend-infrastructure.html 63 kB -501 B (-0.79%)
website/build/docs/api/plugin-methods/i18n-lifecycles.html 60.6 kB -435 B (-0.71%)
website/build/docs/api/plugin-methods/lifecycle-apis.html 170 kB -1.44 kB (-0.84%)
website/build/docs/api/plugin-methods/static-methods.html 46.5 kB -502 B (-1.07%)
website/build/docs/api/plugins.html 31.6 kB -84 B (-0.26%)
website/build/docs/api/plugins/@docusaurus/plugin-client-redirects.html 62.6 kB -675 B (-1.07%)
website/build/docs/api/plugins/@docusaurus/plugin-content-blog.html 172 kB -1.8 kB (-1.04%)
website/build/docs/api/plugins/@docusaurus/plugin-content-docs.html 202 kB -1.72 kB (-0.84%)
website/build/docs/api/plugins/@docusaurus/plugin-content-pages.html 78 kB -949 B (-1.2%)
website/build/docs/api/plugins/@docusaurus/plugin-debug.html 50.5 kB -293 B (-0.58%)
website/build/docs/api/plugins/@docusaurus/plugin-google-analytics.html 51.5 kB -370 B (-0.71%)
website/build/docs/api/plugins/@docusaurus/plugin-google-gtag.html 51 kB -335 B (-0.65%)
website/build/docs/api/plugins/@docusaurus/plugin-google-tag-manager.html 49.8 kB -385 B (-0.77%)
website/build/docs/api/plugins/@docusaurus/plugin-ideal-image.html 51.1 kB -475 B (-0.92%)
website/build/docs/api/plugins/@docusaurus/plugin-pwa.html 122 kB -1.2 kB (-0.97%)
website/build/docs/api/plugins/@docusaurus/plugin-sitemap.html 68.5 kB -477 B (-0.69%)
website/build/docs/api/plugins/@docusaurus/plugin-vercel-analytics.html 42.2 kB -358 B (-0.84%)
website/build/docs/api/themes.html 30.4 kB -79 B (-0.26%)
website/build/docs/api/themes/@docusaurus/theme-classic.html 46.4 kB -205 B (-0.44%)
website/build/docs/api/themes/@docusaurus/theme-live-codeblock.html 38.6 kB -142 B (-0.37%)
website/build/docs/api/themes/@docusaurus/theme-mermaid.html 37.5 kB -121 B (-0.32%)
website/build/docs/api/themes/@docusaurus/theme-search-algolia.html 34.7 kB -48 B (-0.14%)
website/build/docs/api/themes/configuration.html 256 kB -2.36 kB (-0.91%)
website/build/docs/blog.html 211 kB -287 B (-0.14%)
website/build/docs/browser-support.html 51 kB -146 B (-0.29%)
website/build/docs/cli.html 63.8 kB -214 B (-0.33%)
website/build/docs/configuration.html 98.5 kB -394 B (-0.4%)
website/build/docs/create-doc.html 65.3 kB -211 B (-0.32%)
website/build/docs/creating-pages.html 59.1 kB -178 B (-0.3%)
website/build/docs/deployment.html 211 kB -1.11 kB (-0.52%)
website/build/docs/docs-introduction.html 53.6 kB -68 B (-0.13%)
website/build/docs/docs-multi-instance.html 78.7 kB -370 B (-0.47%)
website/build/docs/docusaurus-core.html 245 kB -1.47 kB (-0.6%)
website/build/docs/i18n/crowdin.html 151 kB -869 B (-0.57%)
website/build/docs/i18n/git.html 82.6 kB -289 B (-0.35%)
website/build/docs/i18n/introduction.html 50.7 kB -413 B (-0.81%)
website/build/docs/i18n/tutorial.html 171 kB -575 B (-0.34%)
website/build/docs/installation.html 73 kB -329 B (-0.45%)
website/build/docs/markdown-features.html 83.2 kB -274 B (-0.33%)
website/build/docs/markdown-features/admonitions.html 118 kB -830 B (-0.7%)
website/build/docs/markdown-features/assets.html 93.5 kB -387 B (-0.41%)
website/build/docs/markdown-features/code-blocks.html 245 kB -1.25 kB (-0.51%)
website/build/docs/markdown-features/diagrams.html 56 kB -337 B (-0.6%)
website/build/docs/markdown-features/head-metadata.html 52.8 kB -184 B (-0.35%)
website/build/docs/markdown-features/math-equations.html 95.4 kB -406 B (-0.42%)
website/build/docs/markdown-features/plugins.html 101 kB -270 B (-0.27%)
website/build/docs/markdown-features/react.html 144 kB -521 B (-0.36%)
website/build/docs/markdown-features/tabs.html 148 kB -307 B (-0.21%)
website/build/docs/markdown-features/toc.html 88.7 kB -3.07 kB (-3.35%)
website/build/docs/migration.html 43 kB -105 B (-0.24%)
website/build/docs/migration/v2.html 41.2 kB -305 B (-0.73%)
website/build/docs/migration/v2/automated.html 42.6 kB -55 B (-0.13%)
website/build/docs/migration/v2/manual.html 207 kB -1.67 kB (-0.8%)
website/build/docs/migration/v2/translated-sites.html 52.8 kB -594 B (-1.11%)
website/build/docs/migration/v2/versioned-sites.html 67.2 kB -305 B (-0.45%)
website/build/docs/migration/v3.html 218 kB -1.26 kB (-0.57%)
website/build/docs/search.html 121 kB -443 B (-0.37%)
website/build/docs/seo.html 93 kB -184 B (-0.2%)
website/build/docs/sidebar.html 136 kB -229 B (-0.17%)
website/build/docs/sidebar/autogenerated.html 156 kB -418 B (-0.27%)
website/build/docs/sidebar/items.html 188 kB -646 B (-0.34%)
website/build/docs/sidebar/multiple-sidebars.html 67.1 kB -274 B (-0.41%)
website/build/docs/static-assets.html 56.2 kB -204 B (-0.36%)
website/build/docs/styling-layout.html 140 kB -516 B (-0.37%)
website/build/docs/swizzling.html 120 kB -360 B (-0.3%)
website/build/docs/typescript-support.html 65.4 kB -215 B (-0.33%)
website/build/docs/using-plugins.html 115 kB -385 B (-0.33%)
website/build/docs/versioning.html 87.1 kB -482 B (-0.55%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/codeTranslations.json 2 B 0 B
website/.docusaurus/docusaurus.config.mjs 27.4 kB 0 B
website/.docusaurus/globalData.json 30 kB 0 B
website/.docusaurus/i18n.json 930 B 0 B
website/.docusaurus/registry.js 147 kB 0 B
website/.docusaurus/routes.js 71.6 kB 0 B
website/.docusaurus/routesChunkNames.json 75 kB 0 B
website/.docusaurus/site-metadata.json 2.17 kB 0 B
website/build/assets/css/styles.********.css 112 kB 0 B
website/build/blog.html 62.2 kB -4 B (-0.01%)
website/build/blog/page/2.html 65.4 kB -11 B (-0.02%)
website/build/blog/page/3.html 83.5 kB -11 B (-0.01%)
website/build/blog/page/4.html 58.7 kB -11 B (-0.02%)
website/build/blog/page/5.html 39.1 kB -11 B (-0.03%)
website/build/docs/advanced.html 31.1 kB -13 B (-0.04%)
website/build/docs/advanced/architecture.html 30.6 kB -22 B (-0.07%)
website/build/docs/category/getting-started.html 28.3 kB -29 B (-0.1%)
website/build/docs/category/guides.html 36.4 kB -20 B (-0.05%)
website/build/docs/guides/whats-next.html 32.8 kB -22 B (-0.07%)
website/build/docs/introduction/index.html 280 B 0 B
website/build/docs/markdown-features/links.html 43.1 kB -28 B (-0.06%)
website/build/docs/playground.html 32.5 kB -15 B (-0.05%)
website/build/docs/resources/index.html 325 B 0 B
website/build/docs/support/index.html 319 B 0 B
website/build/docs/team/index.html 310 B 0 B
website/build/index.html 37.8 kB 0 B

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hash navigation breaks in 3.4.0 with some plugins
2 participants