From 45f35a464e84ed6c21d094ecda7a11070ae74b11 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Wed, 5 Oct 2022 07:43:57 +0000 Subject: [PATCH] stream_list: Reduce stream header's height when scrolling elt into view. Since stream header is now sticky, we need to reduce it's height when calculation position of the element we want to scroll into view so that it doesn't hide under the sticky header. --- frontend_tests/node_tests/stream_list.js | 2 ++ static/js/stream_list.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js index 905d4e4142..3c81b39a14 100644 --- a/frontend_tests/node_tests/stream_list.js +++ b/frontend_tests/node_tests/stream_list.js @@ -409,6 +409,7 @@ test_ui("narrowing", ({mock_template}) => { topic_list.rebuild = noop; topic_list.active_stream_id = noop; topic_list.get_stream_li = noop; + $("#streams_header").outerHeight = () => 0; assert.ok(!$("").hasClass("active-filter")); @@ -700,6 +701,7 @@ test_ui("refresh_pin", ({override, override_rewire, mock_template}) => { override_rewire(stream_list, "update_count_in_dom", noop); $("#stream_filters").append = noop; + $("#streams_header").outerHeight = () => 0; let scrolled; override(scroll_util, "scroll_element_into_container", ($li) => { diff --git a/static/js/stream_list.js b/static/js/stream_list.js index 2fc55b7656..cbf55cd303 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -753,8 +753,8 @@ export function scroll_stream_into_view($stream_li) { blueslip.error("Invalid stream_li was passed in"); return; } - - scroll_util.scroll_element_into_container($stream_li, $container); + const stream_header_height = $("#streams_header").outerHeight(); + scroll_util.scroll_element_into_container($stream_li, $container, stream_header_height); } export function maybe_scroll_narrow_into_view() {