From f39886ef57ef5f77b2cc4e16522c1d8ba4d6651f Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 27 Sep 2013 11:40:06 -0400 Subject: [PATCH 1/2] Ensure nav sidebar is sized correctly on page load --- .../src/discussion/views/discussion_thread_list_view.coffee | 1 + 1 file changed, 1 insertion(+) 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..5ce38a4164 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 From cbbb5c7e7e0a107b0c0a0a798b24ead257730a4b Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 27 Sep 2013 16:13:52 -0400 Subject: [PATCH 2/2] Improve focus management of forums nav sidebar Now, when the list is reset (e.g. by sorting), the first thread is focused. When the "Load more" link is clicked, upon loading more threads, focus moves to the thread immediately following the thread that was previously last in the list. --- .../views/discussion_thread_list_view.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 5ce38a4164..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 @@ -144,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) =>