From 473aa295d6222c59125296e9c9f7c62133f0a8c5 Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 25 Dec 2023 12:08:00 +0800 Subject: [PATCH] [dir view, other pages] fixed problems 'cannot close the notice popover (#5854) via clicking the bell icon, or via clicking outside' - in 'dir view', clicking the notice bell icon, clicking the content(dirents) area, the notice popover was not closed - in other pages, clicking the notice bell icon, the popover was not closed --- .../components/common/notification-popover/index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/common/notification-popover/index.js b/frontend/src/components/common/notification-popover/index.js index 24c7a45320..7c7ff52f5d 100644 --- a/frontend/src/components/common/notification-popover/index.js +++ b/frontend/src/components/common/notification-popover/index.js @@ -23,19 +23,15 @@ export default class NotificationPopover extends React.Component { }; componentDidMount() { - document.addEventListener('mousedown', this.handleOutsideClick); + document.addEventListener('mousedown', this.handleOutsideClick, true); } componentWillUnmount() { - document.removeEventListener('mousedown', this.handleOutsideClick); + document.removeEventListener('mousedown', this.handleOutsideClick, true); } handleOutsideClick = (e) => { - if (!this.notificationContainerRef.contains(e.target)) { - document.removeEventListener('mousedown', this.handleOutsideClick); - if (e.target.className === 'tool notification' || e.target.parentNode.className === 'tool notification') { - return; - } + if (!this.notificationContainerRef.contains(e.target) && !document.getElementById('notice-icon').contains(e.target)) { this.props.onNotificationListToggle(); } };