Using the "search this topic" check box blocks search on other pages

AI-generated summary

A bug has been reported where checking the “Search this topic” box blocks search functionality on other pages. elijah was able to reproduce the issue, describing a scenario where the search magnifying glass becomes unresponsive after navigating away from a topic where the “Search this topic” box was checked. Orajnam reported a similar issue, where the top right buttons (search, hamburger, and user icon) become unresponsive.

tgxworld identified the problem as the search context not being reset after navigating away from a route and began working on a fix. A pull request was submitted (tgxworld and later updated with additional fixes ([tgxworld](/t/-/56832/8 and tgxworld).

sam reported that the issue still persisted and provided a step-by-step example of the strange behavior. [tgxworld](/t/-/56832/8 and tgxworld eventually fixed the issue, with the fix now properly tested.

I can reproduce this here.

  1. Click the Search magnifying glass, enter a term, and check the box for “Search this topic”
  2. Click the “Discourse” logo on the upper left.
  3. Click the Search magnifying glass: nothing happens.

A little while later it comes back, but I don’t know if it is some activity I’m doing or what that fixes it.

5 „Gefällt mir“

This is a legit bug @tgxworld and I think Imgur was reporting it as well?

3 „Gefällt mir“

Yup it is the same bug and I’m fixing it atm. Problem here is that the search context is not being reset after we navigate away from the route.

4 „Gefällt mir“

For me, none of the top right buttons work: search, hamburger, or user icon.

Edit: When I come back into the topic where I searched, the search is still showing. ie. it didn’t close when I navigated away from the page.

PR in

https://github.com/discourse/discourse/pull/4684

I found another bug in the process where we did not refresh the results when the search context has changed/become invalid. If you are searching within a topic and you navigate to the home page and open the search menu again, the search results would still be scoped to the topic that you navigated from.

7 „Gefällt mir“

This still acts really really strange … we got to fix it properly.

  1. Search for legit here:

  1. Close search by clicking anywhere

  2. Click “home”

  3. Click “Search”

@tgxworld can you sort this out so it behaves more sanely… I guess if we are not clearing the term we should at least properly reset the search results so it searches globally for legit

6 „Gefällt mir“

Fixed in
https://github.com/discourse/discourse/commit/94622b451a19f0f5152280f146354ab663d06eb8

I’ll need to look at adding the test case next week because it wasn’t straight forward.

5 „Gefällt mir“

Oops I had to do a take 2 on this and this is properly tested now.

https://github.com/discourse/discourse/commit/658b55c4068bad41ce6d78ef70303989f9d6c32c

4 „Gefällt mir“