Skip to content

Commit

Permalink
buddy list: Fix and simplify up/down navigation.
Browse files Browse the repository at this point in the history
This introduces a generic class called list_cursor to handle the
main details of navigating the buddy list and wires it into
activity.js.  It replaces some fairly complicated code that
was coupled to stream_list and used lots of jQuery.

The new code interacts with the buddy_list API instead of jQuery
directly.  It also persists the key across redraws, so we don't
lose our place when a focus ping happens or we type more characters.

Note that we no longer cycle to the top when we hit the bottom, or
vice versa.  Cycling can be kind of an anti-feature when you want to
just lay on the arrow keys until they hit the end.

The changes to stream_list.js here do not affect the left sidebar;
they only remove code that was used for the right sidebar.
  • Loading branch information
Steve Howell authored and timabbott committed Apr 28, 2018
1 parent c63f2db commit fb71202
Show file tree
Hide file tree
Showing 11 changed files with 391 additions and 214 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"user_search": false,
"buddy_data": false,
"buddy_list": false,
"list_cursor": false,
"activity": false,
"invite": false,
"colorspace": false,
Expand Down
23 changes: 12 additions & 11 deletions frontend_tests/casper_tests/03-narrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,22 +470,23 @@ casper.waitForSelector('#user_presences .highlighted_user', function () {

// Use arrow keys to navigate through suggestions
casper.then(function () {
// Down: Cordelia -> Hamlet
casper.sendKeys('.user-list-filter', casper.page.event.key.Down, {keepFocus: true});
// Up: Hamlet -> Cordelia
casper.sendKeys('.user-list-filter', casper.page.event.key.Up, {keepFocus: true});
// Up: Cordelia -> aaron
casper.sendKeys('.user-list-filter', casper.page.event.key.Up, {keepFocus: true});
function arrow(key) {
casper.sendKeys('.user-list-filter',
casper.page.event.key[key],
{keepFocus: true});
}
arrow('Down'); // Cordelia -> Hamlet
arrow('Up'); // Hamlet -> Cordelia
arrow('Up'); // already at top
arrow('Down'); // Cordelia -> Hamlet
});

casper.waitForSelector('#user_presences li.highlighted_user [data-name="aaron"]', function () {
casper.waitForSelector('#user_presences li.highlighted_user [data-name="King Hamlet"]', function () {
casper.test.info('Suggestion highlighting - after arrow key navigation');
casper.test.assertDoesntExist('#user_presences li.highlighted_user [data-name="Cordelia Lear"]',
'User Cordelia Lear not is selected');
casper.test.assertDoesntExist('#user_presences li.highlighted_user [data-name="King Hamlet"]',
'User King Hamlet is not selected');
casper.test.assertExist('#user_presences li.highlighted_user [data-name="aaron"]',
'User aaron is selected');
casper.test.assertExist('#user_presences li.highlighted_user [data-name="King Hamlet"]',
'User King Hamlet is selected');
});

common.then_log_out();
Expand Down
Loading

0 comments on commit fb71202

Please sign in to comment.