-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[docs] Generate unique hash #14632
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] Generate unique hash #14632
Conversation
packages/material-ui-docs/src/MarkdownElement/MarkdownElement.js
Outdated
Show resolved
Hide resolved
|
@mbrookes I'm refactoring the code :) |
Details of bundle changes.Comparing: 6b68487...3fa7dda
|
|
@mbrookes Could you review the changes? I have tried something aggressive. I'm introducing the server side support back of the TOCs. I'm removing the click handler logic, I'm trying to rely on the browser default behaviors. |
|
This is no longer working as intended. Click on API in the TOC here: https://deploy-preview-14632--material-ui.netlify.com/style/icons
For comparison: |
|
It looks like an acceptable tradeoff for me. We win: a simpler logic, a fix of the active state after the first click (can be reproduced in https://next--material-ui.netlify.com/style/icons/). |
|
We might be able to solve the "bottom of the page active link" problem by changing the |
...by removing functionality.
It works for me (or you need to be more specific about what's broken).
I can't think how... and I'd rather not spend more time on it. Let's leave this PR as it was. |
That's the tradeoff, kill features that are too hard to get right. Would you rather have the bottom top active issue or this one (the same item is active forever)?
|
Neither. https://deploy-preview-14548--material-ui.netlify.com/style/icons/#font-icons |
I'm sorry about it, it's the problem when we solve hard problems, it's easy to break: #14629. |
Just because another site is broken, doesn't justify intentionally breaking this one.
Then we fix it whatever that broke, and move on. This code won't have to be visited again for a long time. And if it is, whoever changes it either needs to either test it more carefully (no offence @eps1lon), or write tests. And in case you forgot π :
I'm not sure what you were inspired by, but it looks broken: |
|
Alright let's start fresh @mbrookes Can you describe the behavior you expect? From what I heard it's expected that class based behavior does not translate well into hooks. This is why the react team recommends that only new behavior is implemented with hooks. The more complicated class behavior the more likely you end up with problematic hooks code. Maybe it's better to throw the old code away and rewrite it completely instead of converting it. |
It's even simpler now :). I think that it's a common schema in product development, supporting more cases does not always worth the extra complexity. It can be worse, drain energy away of what's important.
You might want to have a look at the menu item behavior then, same tradeoff for the hover and focus state. I doubt people use both. |
|
@mbrookes I have noticed an important issue with the hash update logic, it's breaking the Next.js previous and next history. As we are talking about simplifications, what do you think of removing this feature too (so we don't have to invest time in fixing this problem)? |



Sorry for yet another hash / TOC related PR (no more, I promise! π ) β but when I was working on the other two, I couldn't help notice the number of duplicate id warnings we were generating.
Warning is nice, but not creating duplicates in the first place is better. This PR fixes that.
(Also DRY up the TOC JSX slightly.)
Here's a good page for comparison:
Check the "Styling solution" links. There are three duplicates, and all three will be highlighted in the TOC when any of them is active.
BTW, I sat on this for PR for a few days, as I couldn't figure out why the active TOC entry wasn't updating correctly, or how this PR could have caused the problem. But since I "knew" that it was working perfectly in the last PR, it must be this one. It was only when I noticed the same behavior in the current published docs (#14628) that I realized it wasn't this PR after all, but rather a certain late modification to said previous PR.
All of which is a long way of saying, please merge this PR before that one. π