Skip to content

Commit

Permalink
[dir view, other pages] fixed problems 'cannot close the notice popov…
Browse files Browse the repository at this point in the history
…er (#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
  • Loading branch information
llj authored Dec 25, 2023
1 parent a64ccc9 commit 473aa29
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions frontend/src/components/common/notification-popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down

0 comments on commit 473aa29

Please sign in to comment.