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

rustdoc: use a button instead of a bar for search #133279

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Nov 21, 2024

r? @GuillaumeGomez

CC @lolbinarycat @liigo

This is an attempt to address three complaints:

  1. The header area takes up a lot of vertical space, and is generally quite "heavy" feeling.

    Fixes [rustdoc] issues of the three-big-buttons #132386

  2. Back and forward are kind of wacky, because there's no "single source of truth" for whether the search mode is open or not. Can't find an issue, but here's a screen recording where I reproduce it.

    screen-record-history-bug.mp4

    https://imgur.com/ZVnHv3o

  3. You can't see the crate picker list, or anything else that we might want to show you, until after you've already typed your search term. [rustdoc search] allow setting crates to search in before showing results #129537 (also notice the example searches, which exist in Hoogle and this tweak adds)

Preview page: https://notriddle.com/rustdoc-html-demo-15/search-button/std/index.html

Video:

screen-record.mp4

https://imgur.com/c37VxLb

Screenshot:

image

image

This is a response to complaints that the header area takes up
too much vertical space, forcing the user to scroll more than
they ought to need. It also adds a reasonable way to pick the
crate name before actually searching, which was also a feature
that people ask for.
@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 Nov 21, 2024
@rust-log-analyzer

This comment has been minimized.

@lolbinarycat
Copy link
Contributor

My immediate concern is how this will look on mobile, expecially with long crate names.

the status quo is already pretty bad.

Screenshot_20241121-005613

@GuillaumeGomez
Copy link
Member

I'm not too sure what to think about it. Turning the search input into a button (to make the search input appear) makes it more tricky to access the search feature.

Also, on mobile it's really not great as the space available is very little.

However I like a few things from this PR:

  1. When we focus on the search focus, we enter the "search page" which allows to give more information to the users.
    • However, on mobile we need a button to leave this "search page"
  2. I like the new layout of the search with the crates filter dropdown above the search input

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
info: ES-Check: there were no ES version matching errors!  🎉
+ eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/externs.js ../src/librustdoc/html/static/js/main.js ../src/librustdoc/html/static/js/scrape-examples.js ../src/librustdoc/html/static/js/search.js ../src/librustdoc/html/static/js/settings.js ../src/librustdoc/html/static/js/src-script.js ../src/librustdoc/html/static/js/storage.js

/checkout/src/librustdoc/html/static/js/search.js
  4459:25  error  'getVar' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)
  local time: Thu Nov 21 16:20:43 UTC 2024
  network time: Thu, 21 Nov 2024 16:20:43 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@notriddle
Copy link
Contributor Author

Turning the search input into a button (to make the search input appear) makes it more tricky to access the search feature.

A little bit, but it does have an explicit "Search" label, and the magnifying glass is very popular anyway.

Also, on mobile it's really not great as the space available is very little.

Here's one concept I came up with to try to claw back more space:
image

When we focus on the search focus, we enter the "search page" which allows to give more information to the users.

I don't want to make focus do that on its own, because it acts badly when tabbing through the page. A switch like that needs to be a button or link.

However, on mobile we need a button to leave this "search page"

The button I have now should act just like a normal link. To exit, use your browser's back button.

It's a very deliberate choice, to avoid bugs like I mentioned under bullet point 2: you should never be in the search page unless the ?search= URL parameter is on there, and the only way to get that URL parameter added is to click the button.

It happens to be implemented in JavaScript, but that should be invisible to the end-user. As far as the interaction model is concerned, that search button should be indistinguishable from an ordinary link. You can even right-click on it and open it in a new tab.

https://imgur.com/ZVnHv3o

@lolbinarycat
Copy link
Contributor

making things behave like links instead of magically doing stuff on hover is much better ux, that's the main reason I abandoned the old popover-on-hover PR.

@GuillaumeGomez
Copy link
Member

The whole mobile experience is big downgrade: the search button is small compared to the rest of the elements, and it's not necessarily obvious what we'll be search. The search input is doing a perfect job for this case.

For desktop, like I said I'm very shared. I like some improvements, but having to click on a button to have access to the search feature is (in my opinion) a big inconvenience. The search in the rust docs is a major feature and something we want to make as accessible as possible. Hiding it behind a button, even if it seems like a small inconvenience is actually (again, since in my opinion) a huge step back.

I don't want to make focus do that on its own, because it acts badly when tabbing through the page. A switch like that needs to be a button or link.

Fair enough. Maybe we could have some "down arrows" button appearing below the search input when focused which would switch to this view?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

[rustdoc] issues of the three-big-buttons
5 participants