Skip to content

rustdoc: use browser-native tooltips for code and notable hover #111856

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

notriddle
Copy link
Contributor

This is the simplest way to adopt the timing guidelines described in https://www.nngroup.com/articles/timing-exposing-content/. It replaces the mouseover interactions used for "tooltip" popovers with HTML title attributes, which already do the right thing.

The JavaScript-based popover code remains for click interaction, so that these elements remain accessible on touch screens, and because it's not possible to put links in native tooltips.

Preview

On-hover tooltip for notable traits

image

On-click popup tip for notable traits (unchanged)

image

This is the simplest way to adopt the timing guidelines described
in <https://www.nngroup.com/articles/timing-exposing-content/>.
It replaces the mouseover interactions used for "tooltip" popovers
with HTML `title` attributes, which already do the right thing.

The JavaScript-based popover code remains for click interaction, so
that these elements remain accessible on touch screens, and because
it's not possible to put links in native tooltips.
@rustbot
Copy link
Collaborator

rustbot commented May 23, 2023

r? @GuillaumeGomez

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 23, 2023
@rustbot
Copy link
Collaborator

rustbot commented May 23, 2023

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @Folyd, @jsha

@GuillaumeGomez
Copy link
Member

I'm not sure having two "views" for the same tooltip is a good idea. Also, what's the size difference in the std?

What do you think about this @rust-lang/rustdoc ?

@Manishearth
Copy link
Member

I find it rather useful that the tooltip content is clickable.

I would rather have us implement the timing requirements.

@notriddle
Copy link
Contributor Author

How about, instead, getting rid of the title attribute and having the popover appear when the button is clicked only?

@Manishearth
Copy link
Member

I find the hover to be quite useful as a hover. I'm not strongly opposed but I would prefer to retain the hover.

@notriddle
Copy link
Contributor Author

@Manishearth Is something like #111892 more what you want?

@Manishearth
Copy link
Member

Looking at the preview, yeah, that looks better. From the guidelines we may want to introduce some instant non-popup hover interaction to the ℹ️, similar to what we have going on with the panic interface, so that people know that an interaction has "registered". Perhaps give it a more muted color that becomes darker, or just make the existing color darker, or give it a shadow, or something.

@jsha
Copy link
Contributor

jsha commented May 31, 2023

FWIW I was searching around for some resources on tooltips and found this page which advises against using "title" to make tooltips. A nice vindication of the conclusion already reached in this PR:

https://inclusive-components.design/tooltips-toggletips/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

5 participants