From d3d6712fa3f4e10858596e4ceef0b0fd9d8352db Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Sat, 1 Jul 2017 20:30:50 +0000 Subject: [PATCH] left-sidebar: Update the size of the scrollbar after narrowing to a stream. --- frontend_tests/node_tests/stream_list.js | 8 ++++++++ static/js/stream_list.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js index 1168c485f4..deb09d9b59 100644 --- a/frontend_tests/node_tests/stream_list.js +++ b/frontend_tests/node_tests/stream_list.js @@ -242,6 +242,11 @@ function initialize_stream_data() { topic_list.rebuild = noop; stream_list.scroll_element_into_container = noop; + var scrollbar_updated = false; + $.stub_selector("#stream-filters-container", { + perfectScrollbar: function () { scrollbar_updated = true; }, + }); + assert(!$('stub-devel').hasClass('active-filter')); stream_list.initialize(); @@ -260,7 +265,9 @@ function initialize_stream_data() { ]); activate_filter(filter); assert($('stub-devel').hasClass('active-filter')); + assert(scrollbar_updated); // Make sure we are updating perfectScrollbar. + scrollbar_updated = false; filter = new Filter([ {operator: 'stream', operand: 'cars'}, {operator: 'topic', operand: 'sedans'}, @@ -268,6 +275,7 @@ function initialize_stream_data() { activate_filter(filter); assert(!$("ul.filters li").hasClass('active-filter')); assert(!$('stub-cars').hasClass('active-filter')); // false because of topic + assert(scrollbar_updated); // Make sure we are updating perfectScrollbar. assert(!pm_expanded); filter = new Filter([ diff --git a/static/js/stream_list.js b/static/js/stream_list.js index 83548998d3..549681a24b 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -461,6 +461,8 @@ exports.initialize = function () { if (stream_li) { exports.scroll_to_active_stream(stream_li); } + // Update scrollbar size. + $("#stream-filters-container").perfectScrollbar("update"); }); $(document).on('narrow_deactivated.zulip', function () {