-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/pkgsite: Reset button for doc examples #17223
Comments
I think this can be solved by exposing a pilcrow (¶) symbol besides the examples too. Because once you have the link, you can just click on it and hit refresh and your page will come back to the original position. This takes care of resetting the example contents and has the added benefit of making the examples more readily shareable. I find it cumbersome to go all the way up the page, find the example anchor link and share it. @gertcuykens - Does that work for you ? |
Yep, that would solve it but don't know if it would be intuitive for others too? |
@agnivade The semantics of all the various expanding/collapsing sections are all over the place. It would be nice if they were unified, possibly including all having ¶s for quick linking as you suggest. They need a lot of work for #22171, probably a full rewrite. There are a lot of edge cases to work out. I could see a reset button being useful, regardless. It might be more user friendly. |
The original issue was that refreshing the page goes to the top because there is nothing to anchor to the example. And putting an anchor solves it. I don't understand where counter-intuitiveness comes into this ?
I am a soft negative on that. I think doing a quick refresh is cleaner than maintaining state and adding a button to revert to that state. Also, adding the button would probably need the change to be propagated to playground also to be consistent. I prefer godoc to be clean and minimalistic as it is. No strong opinions though. |
Agree on minimalistic. By intuitive I mean that everybody has a tendency to just refresh the page in general when something is wrong on the page, by page I mean any website. So if the url get hash tagged automatically when user scrolls down or in my case when I expand the example, then I don't need to know what (¶) stands for. I just refresh the page. Same philosophie as users hitting the back button on a single page app. It's just more intuitive then to click a back link. |
I don't think the url should be hash tagged automatically on expanding the example. That will cause confusion because it will jump to the top of page. The pilcrow symbol will be exposed on mouse-hover, same as the other structs and functions today. Hence, it becomes clear that if you click on the symbol, the example will get anchored and you are then free to refresh the page. I think this is pretty intuitive and explicit behavior. |
Technically you can prevent jumps using https://developer.mozilla.org/en-US/docs/Web/API/History_API But in reality it's to much js effort needed compared to your solution. And I prefer simplicity and consistency over everything so your solution is better :) |
The collapsible section headers (Overview, Index) use the same code as the examples. Would those get ¶ too? Regardless, do they go outside the clickable area of the toggle element? |
Hmm ... yea to be consistent, I would guess they need it too.
I was thinking, we can show the ¶ beside the text (like |
You can't nest Even if nested It would be fine if it went |
Gotcha. I will look into it. |
example: https://golang.org/pkg/html/template/#example_Template_block
The only way to reset a code example when you mest up trying something is to refresh the page. This is annoying if you are on a large page. Note that ussualy you are just on this url https://golang.org/pkg/html/template without a hash tag to the example directly so your page wil jump up when you refresh.
Possible solutions update the hash tag when you expand the example
Or introduce a reset icon somewhere. (where and how i am not sure yet, feel free to discuss)
The text was updated successfully, but these errors were encountered: