From 660144a79d314b8af4c8e7ef76014bb172209401 Mon Sep 17 00:00:00 2001 From: Brock Whittaker Date: Wed, 14 Dec 2016 14:25:49 -0800 Subject: [PATCH] Blur the active element on settings/streams modal exit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This blurs any focused element so that you can’t accidentally enter into anything on a hidden modal. --- static/js/hashchange.js | 1 + static/js/ui.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/static/js/hashchange.js b/static/js/hashchange.js index 488925bd50..ea68c1135f 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -248,6 +248,7 @@ exports.initialize = function () { exports.exit_settings = function (callback) { if (should_ignore(window.location.hash)) { + ui.blur_active_element(); ignore.flag = true; window.location.hash = ignore.prev || "#"; if (typeof callback === "function") { diff --git a/static/js/ui.js b/static/js/ui.js index 205d63ea1b..a470479d5c 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -35,6 +35,11 @@ exports.focus_on = function (field_id) { $("#" + field_id).focus(); }; +exports.blur_active_element = function () { + // this blurs anything that may perhaps be actively focused on. + document.activeElement.blur(); +}; + function amount_to_paginate() { // Some day we might have separate versions of this function // for Page Up vs. Page Down, but for now it's the same