From 45a2d074fbbb607c3a922ae6215b5f057b63106a Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 25 Jul 2017 17:54:35 +0300 Subject: [PATCH] Remove focus from input when opening image viewer Fixes #1342 --- client/js/renderPreview.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/js/renderPreview.js b/client/js/renderPreview.js index 66a4bc8a..563ab99a 100644 --- a/client/js/renderPreview.js +++ b/client/js/renderPreview.js @@ -1,9 +1,9 @@ "use strict"; const $ = require("jquery"); - const options = require("./options"); const templates = require("../views"); +const input = $("#input"); module.exports = renderPreview; @@ -81,15 +81,14 @@ function handleImageInPreview(content, container) { const imageViewer = $("#image-viewer"); -// FIXME Remove #input focus when this is open -// See https://github.com/thelounge/lounge/issues/1342 -$("#viewport").on("click", ".toggle-thumbnail", function() { +$("#chat").on("click", ".toggle-thumbnail", function() { const link = $(this); openImageViewer(link); // Prevent the link to open a new page since we're opening the image viewer, - // but keep it a link to allow for Ctrl/Cmd+click + // but keep it a link to allow for Ctrl/Cmd+click. + // By binding this event on #chat we prevent input gaining focus after clicking. return false; }); @@ -170,4 +169,6 @@ function closeImageViewer() { .one("transitionend", function() { imageViewer.empty(); }); + + input.focus(); }