1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 07:41:26 +00:00

[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
This commit is contained in:
llj
2023-12-25 12:08:00 +08:00
committed by GitHub
parent a64ccc92a3
commit 473aa295d6

View File

@@ -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();
}
};