Method for Navigating Search in this Topic Results

Is there a handler to navigate previous and next through the recent “Search in this Topic” results?

Since lazy loading and virtual lists break browser native Find on all but the shortest topics I think it’s important to replicate that functionality.

I am pretty new to Discourse, I’ve done a search through the meta and the source but I didn’t turn anything up, but it seems like it would be pretty important so I might be missing it. Thanks!

1 like

I think arrow keys should do the trick. You can see the available keyboard shortcuts by clicking the keyboard button in the sidebar on desktop.

The goal is to traverse a topic without bouncing back and forth between the topic and the search results.

In long posts it’s difficult to keep your place in the results, especially as the scroll position resets each time you press a result.

So it would work like the j and k selectUp selectDown handlers except that it would skip over replies that weren’t part of the recent Search this topic results selecting only replies that were.

4 likes

In my estimation it would be reasonable to persist an offscreen list of replies (like an array) and then simply index through them with previousResult nextResult handlers, resetting the list whenever a new topic was loaded or a new search was performed.

Of course keyboard shortcuts and/or buttons would then become trivial.

3 likes

Hey @finder welcome to Discourse!

I am sliding this across to Feature because this sounds like a new feature request. If you could share more insight into the issue you are experiencing, perhaps with a screencast, that would make it easier for us to understand what you are asking about. Can you share more about your setup?

This feels rather complicated to me, since it would remove context.

Actually the Results List already persists across clicks, but there is currently no way to index through results (like a prev/next result button, handler or keyboard shortcut) except manually.

This video shows Find failing since discourse uses Lazy/Virtual lists, so we switch to Search within this topic, but there is no easy way to navigate between results without reopening the search menu, which cover the page, so it must be dismissed to scan over a result, then re-opened, scroll again, manually find the last result we selected, and click the result after that.

It is made worse since the search results cover the page so they must be dismissed to read a post and reopened every time.

If we’re going to replace the browser native Find function, which has existed in its current state since time immemorial, it should be at least equivalent in function.

The list is there, computer are great at moving through lists, and I can’t see anything complicated about it.