Commit cbbb5c7e by Greg Price

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.
parent f39886ef
...@@ -144,6 +144,18 @@ if Backbone? ...@@ -144,6 +144,18 @@ if Backbone?
options.group_id = @group_id 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}) @collection.retrieveAnotherPage(@mode, options, {sort_key: @sortBy})
renderThread: (thread) => renderThread: (thread) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment