fix: copilotkit click ask to close popup

This commit is contained in:
Nevo David 2024-12-27 16:01:57 +07:00
parent 0daa163151
commit 528383a71d
1 changed files with 7 additions and 1 deletions

View File

@ -3,7 +3,13 @@ import { useEffect } from 'react';
export const useClickOutside = (callback: () => Promise<void>) => {
const handleClick = (event: MouseEvent) => {
const selector = document.querySelector('#add-edit-modal');
if (selector && !selector.contains(event.target as HTMLElement)) {
const copilotkit = document.querySelector('.copilotKitPopup');
if (
selector &&
!selector.contains(event.target as HTMLElement) &&
copilotkit &&
!copilotkit.contains(event.target as HTMLElement)
) {
callback();
}
};