From 372e7acfafafaf58b6e4abdaaf13fddf2948090a Mon Sep 17 00:00:00 2001 From: Daniel Calviño Sánchez <danxuliu@gmail.com> Date: Thu, 21 Dec 2017 12:37:35 +0100 Subject: Fix closing menu on second click in sharing page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a "mouseup" event was triggered on any element except on the share menu or its descendants the share menu was closed. The share menu toggle is not a descendant of the share menu, so clicking on it when the share menu was shown closed it by removing its "open" CSS class. However, once that happened the click event was then handled by the share menu toggle, which toggled the "open" CSS class in the share menu and thus added it again. So, from the user point of view, nothing happened when clicking on the share menu toggle if the share menu was open. Now a "mouseup" event on the share menu toggle no longer closes the share menu, and thus toggling the "open" CSS class when handling the "click" event works as expected. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com> --- apps/files_sharing/js/public.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 2142dec1218..ae19500080b 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -434,10 +434,13 @@ $(document).ready(function () { $(document).mouseup(function(e) { + var toggle = $('#share-menutoggle'); var container = $('#share-menu'); - // if the target of the click isn't the container nor a descendant of the container - if (!container.is(e.target) && container.has(e.target).length === 0) { + // if the target of the click isn't the menu toggle, nor a descendant of the + // menu toggle, nor the container nor a descendant of the container + if (!toggle.is(e.target) && toggle.has(e.target).length === 0 && + !container.is(e.target) && container.has(e.target).length === 0) { container.removeClass('open'); } }); -- cgit v1.2.3