J/k keyboard navigation doesn't function on Profile or Messages pages

keyboard

(TechnoBear) #1

On other category pages, j/k can be used to navvigate the threads, but it’s not functioning on Profile or Messages pages.


(cpradio) #2

Let’s discuss the expected behavior a bit on this one too :smile:

So j/k should navigate up/down respectively, do you expect o/enter to open the post/message? – That sounds reasonable to me.


(TechnoBear) #3

Yes - that’s what I would expect. Basically, the same functionality as on a category page.


(cpradio) #4

Okay, so this is fairly complicated. I was able to add support for j/k on the user activity page, but there are bugs that I haven’t a clue how to fix.

So what I’ve done up to this point:

/discourse/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js
add o and enter support

'o,enter': '.topic-list tr.selected a.title,.user-stream .item.selected .title a',                 // open selected topic

added user-stream logic to _findArticles

  _findArticles: function() {
    var $topicList = $('.topic-list'),
        $topicArea = $('.posts-wrapper'),
        $userStream = $('.user-stream');

    if ($topicArea.size() > 0) {
      return $('.posts-wrapper .topic-post, .topic-list tbody tr');
    }
    else if ($topicList.size() > 0) {
      return $topicList.find('.topic-list-item');
    }
    else if ($userStream.size() > 0) {
      return $userStream.find('.item');
    }
  },

/discourse/app/assets/stylesheets/common/components/keyboard_shortcuts.css.scss
Added .item.selected so the user activity stream gets the left border for the selected item

.topic-list tr.selected td:first-child, .topic-list-item.selected td:first-child, .topic-post.selected, .item.selected {
  border-left: 1px solid $danger;
}

Okay, so this gets j/k to “sort of” work on the user activity stream. However, once you get to the bottom of the page, the data seems to get wiped out and reloaded, and thus it loses your place and you have to start from the top all over again.

I haven’t found where this is happening, but I imagine it is related to the following topics:

https://github.com/discourse/discourse/commit/f05d2ed7cffa086aa674a51d52ed5f344142a372

Messages are a whole different issue. The topics do not have a class name associated to them, so showing selection is difficult. I’m not sure how or why the class name was removed (I imagine it was to remove the j/k keys from working) and I haven’t figured out how the class name gets removed yet.

I’m not sure what to do or how to go about fixing it :frowning:


(TechnoBear) #5

This issue now also affects the extended “notifications” page.

Tab down the notifications menu until “view older notifications…” and press Enter. This takes you to https://meta.discourse.org/users/myself/notifications, where you have to tab through everything from the top of the page, including the notifications you’ve already tabbed through, before making any progress.

(A temporary fix to at least make the process a little less tedious would be to move the “view older notifications” link to the top of the menu, where it might look odd, but would at least reduce the number of links to be tabbed through, and remove the necessity of tabbing through some of them twice.)


(TechnoBear) #6

Just to update: j/k navigation now works on messages. Thank you to whoever is responsible for that. :smiley:

Still doesn’t function on Profile page, though.