Skip to content
Snippets Groups Projects
Commit f1cf2d13 authored by dw927's avatar dw927
Browse files

Fixed a bug where images would duplicate when closing dialog with escape key.

parent 9808c6af
No related branches found
No related tags found
No related merge requests found
......@@ -38,3 +38,18 @@ function createNewTabLink(imageUrl) {
button.classList.add('dialog-button');
return button;
}
document.onkeydown = function(evt) {
evt = evt || window.event;
var isEscape = false;
if ("key" in evt) {
isEscape = (evt.key === "Escape" || evt.key === "Esc");
} else {
isEscape = (evt.keyCode === 27);
}
if (isEscape) {
while (dialog.hasChildNodes()) {
dialog.removeChild(dialog.firstChild);
}
}
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment