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

Reset the docs' copy path button after 1 second #84740

Merged
merged 3 commits into from
May 1, 2021

Conversation

wooster0
Copy link
Contributor

@wooster0 wooster0 commented Apr 30, 2021

I like that this copy path button on the top next to the type/module's name changes to a check mark when you successfully clicked and copied the path but I find it really weird how the icon stays that check mark forever after the first time of clicking it. Imagine you leave that documentation tab open and come back after 2 hours and you still see that check mark in that box because you copied the path 2 hours ago. You will probably be confused and you might've forgotten what that button even does (even more so currently where this is a new feature, or when you simply don't use it often), so I really think at some point it should go back to the ⎘ icon which, at least to me, pretty clearly indicates copying, whereas the check mark (if it stays there for so long) could falsely look like a verification mark indicating "this module is verified" or something like that.
I believe after a longer period of time it's not logical to still tell the user "yes you've copied this successful".

In addition to this timeout, maybe it could be made so that you can't copy again until this cooldown of 1 second is over, but I'm not sure how useful or user-friendly that feature would be so maybe it's fine the way it is now.
Also the timeout is cleared every time you click again so if you constantly click it, it won't reset during that.

@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rust-highfive
Copy link
Collaborator

r? @CraftSpider

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 30, 2021
@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-js Area: Rustdoc's JS front-end labels Apr 30, 2021
@@ -1513,4 +1515,12 @@ function copy_path(but) {
document.body.removeChild(el);

but.textContent = '✓';

window.clearTimeout(reset_button_timeout);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rust-log-analyzer

This comment has been minimized.

@wooster0
Copy link
Contributor Author

In that failed build log I can see:

2021-04-30T08:45:32.6524935Z some tidy checks failed

Maybe uninitialized declarations like let reset_button_timeout; aren't allowed?

@GuillaumeGomez
Copy link
Member

let isn't allowed.

@@ -1490,6 +1490,8 @@ function hideThemeButtonState() {
searchState.setup();
}());

let reset_button_timeout;
Copy link
Member

Choose a reason for hiding this comment

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

I really don't like global variables like this. Instead, please wrap copy_path into an anonymous function like we do in multiple places here and move the reset_button_timeout declaration there.

Another thing: even though it's valid to send an undefined variable to clearTimeout, please initialize your value to null and check it before calling clearTimeout.

window.clearTimeout(reset_button_timeout);

function reset_button() {
but.textContent = '⎘';
Copy link
Member

Choose a reason for hiding this comment

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

Please reset reset_button_timeout to null in here.

path.push(child.textContent);
}
});
function copy_path(but) {
Copy link
Member

Choose a reason for hiding this comment

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

You need to put this function into window, otherwise the onclick event won't find it.

window.copy_path = copy_path;

Or you can declare it directly like this:

Suggested change
function copy_path(but) {
window.copy_path = function(but) {

(and don't forget the ; at the end ;) )

@GuillaumeGomez
Copy link
Member

Thanks!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Apr 30, 2021

📌 Commit bea99a5 has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 30, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 30, 2021
Reset the docs' copy path button after 1 second

I like that this copy path button on the top next to the type/module's name changes to a check mark when you successfully clicked and copied the path but I find it really weird how the icon stays that check mark forever after the first time of clicking it. Imagine you leave that documentation tab open and come back after 2 hours and you still see that check mark in that box because you copied the path 2 hours ago. You will probably be confused and you might've forgotten what that button even does (even more so currently where this is a new feature, or when you simply don't use it often), so I really think at some point it should go back to the ⎘ icon which, at least to me, pretty clearly indicates copying, whereas the check mark (if it stays there for so long) could falsely look like a verification mark indicating "this module is verified" or something like that.
I believe after a longer period of time it's not logical to still tell the user "yes you've copied this successful".

In addition to this timeout, maybe it could be made so that you can't copy again until this cooldown of 1 second is over, but I'm not sure how useful or user-friendly that feature would be so maybe it's fine the way it is now.
Also the timeout is cleared every time you click again so if you constantly click it, it won't reset during that.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request May 1, 2021
Reset the docs' copy path button after 1 second

I like that this copy path button on the top next to the type/module's name changes to a check mark when you successfully clicked and copied the path but I find it really weird how the icon stays that check mark forever after the first time of clicking it. Imagine you leave that documentation tab open and come back after 2 hours and you still see that check mark in that box because you copied the path 2 hours ago. You will probably be confused and you might've forgotten what that button even does (even more so currently where this is a new feature, or when you simply don't use it often), so I really think at some point it should go back to the ⎘ icon which, at least to me, pretty clearly indicates copying, whereas the check mark (if it stays there for so long) could falsely look like a verification mark indicating "this module is verified" or something like that.
I believe after a longer period of time it's not logical to still tell the user "yes you've copied this successful".

In addition to this timeout, maybe it could be made so that you can't copy again until this cooldown of 1 second is over, but I'm not sure how useful or user-friendly that feature would be so maybe it's fine the way it is now.
Also the timeout is cleared every time you click again so if you constantly click it, it won't reset during that.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 1, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#84601 (rustdoc: Only store locations in Cache::extern_locations and calculate the other info on-demand)
 - rust-lang#84704 (platform-support.md: Update for consistency with Target Tier Policy)
 - rust-lang#84724 (Replace llvm::sys::fs::F_None with llvm::sys::fs::OF_None)
 - rust-lang#84740 (Reset the docs' copy path button after 1 second)
 - rust-lang#84749 (Sync `rustc_codegen_cranelift`)
 - rust-lang#84756 (Add a ToC to the Target Tier Policy documentation)
 - rust-lang#84765 (Update cargo)
 - rust-lang#84774 (Fix misspelling)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a4dbb8c into rust-lang:master May 1, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 1, 2021
@wooster0 wooster0 deleted the patch-6 branch September 24, 2021 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-js Area: Rustdoc's JS front-end S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants