Keyboard nagivation on the search page

AI-generated summary

Keyboard Navigation on the Search Page

Users schleifer and maiki requested keyboard navigation on the search results page, similar to topic lists. sam noted that search results already support navigation with up/down arrows and the a key to add to composer. However, users wanted to use j, k, o, and u keys instead.

Dan implemented the requested feature, and maiki asked about the context of using a to add to composer. Dan explained that j and k would not work in the search modal because they would append to the search input. He also added these shortcuts to the keyboard shortcuts modal.

However, schleifer reported an issue where o would not enter the selected topic, but instead load the last displayed result. Dan pushed a fix for the issue, and sam confirmed that the feature is now working as expected.

After you start a search with ‘/’, type your query, and submit with Enter, then it takes you to the results screen:

You can move through these with much tabbing, but it would be much more convenient to use j/k/o/u like you can in topic lists.

16 Likes

I would also like search results to work with keyboard navigation. :slight_smile:

3 Likes

They already do, up / down arrow… a to add to composer:

@dan how hard is adding j k support to full page search?

8 Likes

Not too hard :slight_smile:

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

10 Likes

Could you expand on that? The composer is the…

Oh, I get it! Haha, the path reveals itself.

Hey, any reason it shifts to up/down rather than j/k in that context? Because I was adding my support to the navigation for the full search page, but I had actually not known about the up/down but definitely tried the j/k in the search modal. :dizzy_face:

Only J or K would not work because you would be appending J and K to the search input. You would have to either use Tab, ↓, the mouse or some other key.

EDIT: I included these shortcuts in keyboard shortcuts modal ?:

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

5 Likes

Thanks! It became apparent to me (just like the “a to append” above) later, when I actually used the search that suddenly made all the sense.

Thanks folks!

1 Like

This worked for a while, but has gotten weird.

j/k will go up and down on the list, but o doesn’t enter the selected topic. Instead it always loads the currently last displayed result. (Or number 50 if there are more than that in the results.)

What I did:

  1. hit / to open the search box
  2. type something
  3. hit return
  4. j to move down the list 2 items
    Can I Admit Something...? 🤔 is the selected title
  5. hit o

What I expected to load:

What actually loads:

3 Likes

Just pushed a fix for your issue. It should be working as expected now.

https://github.com/discourse/discourse/commit/402194f313257021549d23514969bc69dd0274e5

4 Likes

This is up and running and working well.

1 Like