From c894f50f3c02f6cfadc819ee49f35394da0c040e Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Fri, 3 Dec 2021 14:40:13 +0000 Subject: [PATCH] recent_topics: Extend persistent focus bug to all RT elements. The bug fix for RT search, also needs to be applied to other elements. Fixes #19458. --- static/js/recent_topics_ui.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.js index b307874d05..785e6c2ef7 100644 --- a/static/js/recent_topics_ui.js +++ b/static/js/recent_topics_ui.js @@ -639,15 +639,19 @@ function filter_buttons() { } export function hide() { + // On firefox (and flaky on other browsers), focus + // remains on the focused element even after it is hidden. We + // forcefully blur it so that focus returns to the visible + // focused element. + const focused_element = $(document.activeElement); + if ($("#recent_topics_view").has(focused_element)) { + focused_element.trigger("blur"); + } + $("#message_view_header_underpadding").show(); $("#message_feed_container").show(); $("#recent_topics_view").hide(); set_visible(false); - // On firefox (and flaky on other browsers), focus - // remains on search box even after it is hidden. We - // forcefully blur it so that focus returns to the visible - // focused element. - $("#recent_topics_search").trigger("blur"); $(".header").css("padding-bottom", "10px");