hotkeys: Expand collapsed sidebars when sidebar searches are initiated.

Fixes #7351.
This commit is contained in:
Cynthia Lin 2017-10-11 20:07:12 -07:00 committed by Tim Abbott
parent 7d2672cfcd
commit 940ca17c46
3 changed files with 40 additions and 1 deletions

View File

@ -42,6 +42,20 @@ set_global('blueslip', {
log: function () {},
});
set_global('popovers', {
hide_all: function () {},
show_userlist_sidebar: function () {
$('.column-right').addClass('expanded');
},
});
set_global('stream_popover', {
show_streamlist_sidebar: function () {
$('.column-left').addClass('expanded');
},
});
set_global('reload', {
is_in_progress: function () {return false;},
});
@ -583,7 +597,19 @@ $('.user-list-filter').is = function (sel) {
(function test_initiate_search() {
$('.user-list-filter').blur();
$('.user-list-filter').closest = function (selector) {
assert.equal(selector, ".app-main [class^='column-']");
return $.create('right-sidebar').addClass('column-right');
};
activity.initiate_search();
assert.equal($('.column-right').hasClass('expanded'), true);
assert.equal($('.user-list-filter').is_focused(), true);
$('.user-list-filter').closest = function (selector) {
assert.equal(selector, ".app-main [class^='column-']");
return $.create('left-sidebar').addClass('column-left');
};
activity.initiate_search();
assert.equal($('.column-left').hasClass('expanded'), true);
assert.equal($('.user-list-filter').is_focused(), true);
}());

View File

@ -536,6 +536,15 @@ exports.escape_search = function () {
exports.initiate_search = function () {
var filter = $('.user-list-filter').expectOne();
var column = $('.user-list-filter').closest(".app-main [class^='column-']");
if (!column.hasClass("expanded")) {
popovers.hide_all();
if (column.hasClass('column-left')) {
stream_popover.show_streamlist_sidebar();
} else if (column.hasClass('column-right')) {
popovers.show_userlist_sidebar();
}
}
filter.focus();
};

View File

@ -507,8 +507,12 @@ exports.clear_search = function () {
exports.initiate_search = function () {
var filter = $('.stream-list-filter').expectOne();
filter.parent().removeClass('notdisplayed');
filter.focus();
$('#clear_search_stream_button').prop('disabled', false);
if (!$(".app-main .column-left").hasClass("expanded")) {
popovers.hide_all();
stream_popover.show_streamlist_sidebar();
}
filter.focus();
};
exports.clear_and_hide_search = function () {