Skip to content

Commit

Permalink
chore: fix onClose of filters side panel
Browse files Browse the repository at this point in the history
  • Loading branch information
amlannandy committed Jan 29, 2025
1 parent 4ed73dc commit 69743a5
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ function K8sFiltersSidePanel({
}
}, [searchValue]);

// Close side panel when clicking outside of it
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
sidePanelRef.current &&
!sidePanelRef.current.contains(event.target as Node)
) {
onClose();
}
};

document.addEventListener('mousedown', handleClickOutside);

return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<div className="k8s-filters-side-panel-container">
<div className="k8s-filters-side-panel" ref={sidePanelRef}>
Expand Down

0 comments on commit 69743a5

Please # to comment.