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] Do not repeat language snippet in url in Algolia search #29483

Merged
merged 4 commits into from
Nov 11, 2021

Conversation

hbjORbj
Copy link
Member

@hbjORbj hbjORbj commented Nov 3, 2021

Closes #29332
Closes #29461

Problem:

  • When user is using a language other than English, links in Algolia search contain the language snippet (zh or pt). This results in repetition of the language snippet in url; e.g., https://mui.com/zh/zh/components/buttons/#main-content
  • This is because mui.com already changes to mui.com/${language} if language other than English is set.
  • To reproduce, follow these steps:
    (1) Go to https://mui.com/getting-started/usage/
    (2) Change language setting to Portuguese
    (3) Open algolia searchbox and enter "mig"
    (4) Click the first link
    (4) You will be directed to https://mui.com/pt/pt/guides/migration-v4/#main-content

Solution:

  • When user is using language other than English, remove the language snippet (zh or pt) from urls used in algolia search.

Preview: https://deploy-preview-29483--material-ui.netlify.app/

@mui-pr-bot
Copy link

mui-pr-bot commented Nov 3, 2021

No bundle size changes

Generated by 🚫 dangerJS against a7f1d81

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 3, 2021

It's not solving the root issue. Now, when you use Enter to validate a result, you lose the language prefix.

Actually, something else is wrong, keyboard interactions do a hard navigation, it's wrong, it should be client-side navigation.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work docs Improvements or additions to the documentation labels Nov 3, 2021
@hbjORbj
Copy link
Member Author

hbjORbj commented Nov 10, 2021

@oliviertassinari I addressed your points. It's working on my local server. Let me know.

cc Algolia keyboard navigator ref

@oliviertassinari oliviertassinari added the regression A bug, but worse label Nov 10, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 11, 2021

I noticed one issue when using the Enter key.

Screenshot 2021-11-11 at 01 40 18

I have a quick fix coming next.

@@ -277,7 +277,7 @@ function AppFrame(props) {
{LANGUAGES_LABEL.map((language) => (
<MenuItem
component="a"
data-no-link="true"
data-no-markdown-link="true"
Copy link
Member

Choose a reason for hiding this comment

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

What is this for? No objection, just want to know what it does.

Copy link
Member

@oliviertassinari oliviertassinari Nov 11, 2021

Choose a reason for hiding this comment

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

MarkdownLinks.js tries to handle all the <a> clicks. This was done to have smooth routing navigation on the markdown. data-no-markdown-link opt-out from this behavior.

@hbjORbj hbjORbj merged commit cd247a1 into mui:master Nov 11, 2021
@oliviertassinari oliviertassinari added the i18n internationalization label Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation i18n internationalization regression A bug, but worse
Projects
None yet
4 participants