From bbc4a9356c59d9788a9133adb1e65fc4bd5bc32e Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Fri, 15 Nov 2019 13:02:08 +0000 Subject: [PATCH] added listener to close user control --- src/scripts/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/scripts/index.js b/src/scripts/index.js index 9091310..a3412a6 100644 --- a/src/scripts/index.js +++ b/src/scripts/index.js @@ -81,6 +81,12 @@ document.addEventListener('DOMContentLoaded', function (event) { } }).catch(error => console.log(error)); - + // Document -> close menu + document.addEventListener("click", event => { + if (!event.target.closest('#user-controls')) { + let userControls = this.querySelector('#user-controls'); + if (userControls) userControls.removeAttribute("open"); + } + }); }); \ No newline at end of file