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

[docs-infra] Error when clicking on logo link in AppBarWithResponsiveMenu demo #38451

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

maheshguntur
Copy link
Contributor

@maheshguntur maheshguntur commented Aug 13, 2023

Error when clicked LOGO in below example Appbar
https://mui.com/material-ui/react-app-bar/#app-bar-with-responsive-menu

uncaught typeerror when clicked on Appbar LOGO - mui website

Replicated the error in local
uncaught typeerror when clicked on Appbar LOGO - local

Fixes #38412

@mui-bot
Copy link

mui-bot commented Aug 13, 2023

Netlify deploy preview

https://deploy-preview-38451--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 5fbebb3

@maheshguntur
Copy link
Contributor Author

maheshguntur commented Aug 13, 2023

I saw there is an issue on this and some one already assigned to it

@raphaelricardo10
Copy link

It seems a reasonable solution. Is it working locally?

You should provide a label to pass the remaining test.

@maheshguntur
Copy link
Contributor Author

maheshguntur commented Aug 14, 2023

yes. It is working in local. I do not have an option to add label.

no error in local for app bar

@maheshguntur maheshguntur reopened this Aug 14, 2023
@zannager zannager added docs Improvements or additions to the documentation component: app bar This is the name of the generic UI component, not the React module! labels Aug 15, 2023
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maheshguntur The root issue is different. I encounter the same problem on all links that use href="/". Here are a couple of examples:

The error states that it can't read the name property of productIdentifier, which corresponds to the code for App Nav Drawer. What confuses me is why the AppNavDrawer component is being invoked when redirecting to the homepage. cc @mui/docs-infra @oliviertassinari

@ZeeshanTamboli ZeeshanTamboli added the bug 🐛 Something doesn't work label Aug 18, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [docs][App Bar]: AppBarWithResponsiveMenu logo href link [docs][material-ui] Error when clicking on logo link in AppBarWithResponsiveMenu demo Aug 18, 2023
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 20, 2023

What confuses me is why the AppNavDrawer component is being invoked when redirecting to the homepage.

Yes! Confusion is such a great state of mind to be in, It never stops giving, to drill down until it makes 100% sense. In our case, I think a bug in the Next.js Pages Router but that is exacerbated by a buggy logic we have.

diff --git a/docs/src/modules/utils/helpers.ts b/docs/src/modules/utils/helpers.ts
index d8c774cfa6..0057c707e9 100644
--- a/docs/src/modules/utils/helpers.ts
+++ b/docs/src/modules/utils/helpers.ts
@@ -100,7 +100,13 @@ export function pathnameToLanguage(pathname: string): {
   // Remove hash as it's never sent to the server
   // https://github.com/vercel/next.js/issues/25202
   const canonicalAsServer = canonicalAs.replace(/#(.*)$/, '');
-  const canonicalPathname = canonicalAsServer.replace(/^\/api/, '/api-docs').replace(/\/$/, '');
+  let canonicalPathname = canonicalAsServer.replace(/^\/api/, '/api-docs');
+
+  // Remove trailing slash as Next.js doesn't expect it here
+  // https://nextjs.org/docs/pages/api-reference/functions/use-router#router-object
+  if (canonicalPathname !== '/') {
+    canonicalPathname = canonicalPathname.replace(/\/$/, '');
+  }

   return {
     userLanguage,

I changed the reviewer, I think it's more important for Alexandre to gain awareness of this.

@oliviertassinari oliviertassinari added scope: docs-infra Specific to the docs-infra product and removed docs Improvements or additions to the documentation component: app bar This is the name of the generic UI component, not the React module! labels Aug 20, 2023
@oliviertassinari oliviertassinari changed the title [docs][material-ui] Error when clicking on logo link in AppBarWithResponsiveMenu demo [docs-infra] Error when clicking on logo link in AppBarWithResponsiveMenu demo Aug 20, 2023
@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Aug 20, 2023
@oliviertassinari oliviertassinari requested review from alexfauquette and removed request for siriwatknp August 20, 2023 15:52
@alexfauquette alexfauquette merged commit 9f03b77 into mui:master Sep 19, 2023
19 checks passed
christophermorin pushed a commit to christophermorin/material-ui that referenced this pull request Sep 21, 2023
Co-authored-by: alexandre <alex.fauquette@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs] Redirect when clicking in app bar logo is causing a client-side exception
7 participants