Skip to content

Commit

Permalink
Merge pull request thelounge#1370 from thelounge/xpaw/image-viewer-focus
Browse files Browse the repository at this point in the history
Remove focus from input when opening image viewer
  • Loading branch information
astorije committed Jul 25, 2017
2 parents 8711a50 + fca149b commit 781e7b1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/js/renderPreview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

const $ = require("jquery");

const options = require("./options");
const templates = require("../views");
const input = $("#input");

module.exports = renderPreview;

Expand Down Expand Up @@ -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;
});

Expand Down Expand Up @@ -170,4 +169,6 @@ function closeImageViewer() {
.one("transitionend", function() {
imageViewer.empty();
});

input.focus();
}

0 comments on commit 781e7b1

Please sign in to comment.