diff --git a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee index 2fc31da97a..8259004893 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee @@ -95,6 +95,7 @@ if Backbone? @timer = 0 @$el.html(@template()) + $(window).bind "load", @updateSidebar $(window).bind "scroll", @updateSidebar $(window).bind "resize", @updateSidebar @@ -143,6 +144,18 @@ if Backbone? options.group_id = @group_id + lastThread = @collection.last()?.get('id') + if lastThread + # Pagination; focus the first thread after what was previously the last thread + @once("threads:rendered", -> + $(".post-list li:has(a[data-id='#{lastThread}']) + li a").focus() + ) + else + # Totally refreshing the list (e.g. from clicking a sort button); focus the first thread + @once("threads:rendered", -> + $(".post-list a").first()?.focus() + ) + @collection.retrieveAnotherPage(@mode, options, {sort_key: @sortBy}) renderThread: (thread) =>