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

[Extremely Minor] Search Query Stays in URL on Documentation #936

Closed
peblair opened this issue May 18, 2015 · 10 comments
Closed

[Extremely Minor] Search Query Stays in URL on Documentation #936

peblair opened this issue May 18, 2015 · 10 comments

Comments

@peblair
Copy link

peblair commented May 18, 2015

I've noticed something while using the search functionality on the docs (Disclaimer: This might not even be a real problem; I just thought I would mention it in case. If it's not a problem, I apologize for taking up space in the issue queue):

Steps to Reproduce

  1. Type in a search query, say foo into the search bar and press enter
  2. Click "Top" to return to the main documentation page

Expected Behavior

A URL of http://docs.racket-lang.org/index.html

Actual Behavior

A URL of http://docs.racket-lang.org/index.html?q=foo

@samth
Copy link
Sponsor Member

samth commented May 18, 2015

This is somewhat intentional, so that the search query is remembered the next time you go to search. I also find it annoying, though, so I'd prefer to remove it.

@elibarzilay
Copy link
Member

This is a combination of two things:

  1. Entering a string in the search box uses a url parameter to pass the search string to the search page.
  2. All pages intentionally tweak URLs to keep any such parameters. You can see that by going to http://docs.racket-lang.org/?xxx=yyy -- all links will have that at the end.

I don't remember the reason, but this was definitely intentional -- I remember that Matthew added this functionality at some point (I remember that at that point I stopped using the top-left search box, to avoid the sticky parameter).

@samth
Copy link
Sponsor Member

samth commented May 18, 2015

Looks like this was added here: racket/scribble@2eb8e45 by @elibarzilay. I'm looking for discussion now.

@samth
Copy link
Sponsor Member

samth commented May 18, 2015

I've been unable to find any discussion about this change from 2009, although I think I remember something about it.

@elibarzilay
Copy link
Member

Perhaps it was me who wrote the code, but I still don't like it... In any case, there were several possible reasons for doing this: (1) there was the attempt to get to the docs from the teaching language in a way that remembers that context (so you won't find other documentation bits); (2) there was some potential mess if you have multiple versions (and that was somehow done with cookies, too, maybe?); and (3) there was the problem of remembering where to go back to if you start in a page in your local doc directory, then go to some page that is in the installation (and/or going in the other direction).

@lexi-lambda
Copy link
Member

I accidentally stumbled upon this issue over a year later, but I’d like to say that I agree this behavior is annoying. I use the search box a lot, but when I link people to documentation I always have to manually strip the query string off of the URL. I personally don’t think it’s a worthwhile feature, but I would imagine some people might find it to be a better user experience, so I wouldn’t mind too much if it were kept as-is.

@sorawee
Copy link
Collaborator

sorawee commented Aug 7, 2020

Another annoying issue: the back button doesn't work the way it's supposed to. Consider:

  1. Search for print in the top left corner text box. Enter.
  2. The search result is shown. I decide to refine my search to println by adding ln at the end. Choose the first result.
  3. Click Back. Now we are at the search result for print again instead of println.

@sorawee
Copy link
Collaborator

sorawee commented Aug 7, 2020

Note that I believe the query string is there to support the immediate Back button. This is a must-have feature, but it should be doable without using the query string hack.

@jcmdln
Copy link

jcmdln commented Aug 7, 2020

Based on my read of this issue and the responses, it seems the additional query string is primarily meant to preserve search queries to allow for forward/backward navigation in a web browser. Simply by adding this query string, browsers will be able to navigate between pages as expected so there is no need to manipulate all URLs.

This is the current behavior at the time of writing:

When the result of a search shows a list of prospective links, following these links as shown above does not result in populating the top-left search field with the current search parameter. Due to this, there appears to be no need for this context to be preserved once a link would result in the user leaving the route docs.racket-lang.org/search. A raw example of what a subjectively "ideal" behavior might look like is simply not appending this query to all URLs on the page, as navigation will work as expected:

Solution (WIP)

server-side, when a search is completed I'd like for an HTTP cookie to be set. This can be handled bidirectionally in JS or Racket, so I'll see what seems like "the right way". Coupling that with the History API and invalidating stale cookies, if set, seems to cover most of the cases I can think of.

Client-Side

Server-Side

I'll stew on this a little and think through the problem more meaningfully. Thanks to @sorawee and @samth for bouncing ideas in #triage@slack, seems we have a few ways of reaching improved behavior.

@jackfirth
Copy link
Sponsor Contributor

@mflatt Thanks so much for fixing this, it's been bugging me for years

maueroats pushed a commit to maueroats/racket that referenced this issue Jun 17, 2021
When you search in a page other than the main search page, the search
request is communicated as a "q" query in the URL. Meanwhile, the search
page generally propagates all query arguments, as a kind of store-passing
facility, which means that the "q" query was passed along. Avoid adding the
"q" to search results, so it doesn't get propagated so much.

Closes racket#936
maueroats pushed a commit to maueroats/racket that referenced this issue Jun 17, 2021
When you search in a page other than the main search page, the search
request is communicated as a "q" query in the URL. Meanwhile, the search
page generally propagates all query arguments, as a kind of store-passing
facility, which means that the "q" query was passed along. Avoid adding the
"q" to search results, so it doesn't get propagated so much.

Closes racket#936
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants