diff --git a/apps/web/src/components/dialogs/AiAssistantDialog.tsx b/apps/web/src/components/dialogs/AiAssistantDialog.tsx
index d491528a..9325694e 100644
--- a/apps/web/src/components/dialogs/AiAssistantDialog.tsx
+++ b/apps/web/src/components/dialogs/AiAssistantDialog.tsx
@@ -49,6 +49,13 @@ import { cn } from "@/lib/utils";
const FREEFORM_VALUE = "custom";
const PROMPT_VALUE_PREFIX = "prompt:";
+const AI_ASSISTANT_LAYER_SELECTOR = '[data-edgeever-ai-assistant-layer="true"]';
+
+export const isAiAssistantPointerTarget = (target: EventTarget | null, panel: HTMLElement | null) => {
+ if (!(target instanceof Node)) return false;
+ if (panel?.contains(target)) return true;
+ return target instanceof Element && Boolean(target.closest(AI_ASSISTANT_LAYER_SELECTOR));
+};
const promptSelectValue = (id: string) => `${PROMPT_VALUE_PREFIX}${id}`;
@@ -182,9 +189,7 @@ export const AiAssistantDialog = ({
if (!open) return;
const frame = window.requestAnimationFrame(() => instructionRef.current?.focus());
const handlePointerDown = (event: PointerEvent) => {
- const target = event.target;
- if (!(target instanceof Node) || panelRef.current?.contains(target)) return;
- if (target instanceof Element && target.closest('[data-radix-popper-content-wrapper], [role="dialog"]')) return;
+ if (isAiAssistantPointerTarget(event.target, panelRef.current)) return;
onOpenChange(false);
};
window.addEventListener("pointerdown", handlePointerDown);
@@ -432,7 +437,7 @@ export const AiAssistantDialog = ({
-
+
{prompts.length ? (
{t("aiAssistant.myPrompts")}
@@ -480,7 +485,7 @@ export const AiAssistantDialog = ({
-
+
{targetLanguages.map((language) => (
{t(`aiAssistant.targetLanguages.${language}`)}
))}
@@ -496,7 +501,7 @@ export const AiAssistantDialog = ({
clearResult();
}}>
-
+
{aiTones.map((item) => {t(`aiAssistant.tones.${item}`)})}
@@ -659,7 +664,7 @@ export const AiAssistantDialog = ({
createPromptMutation.reset();
}
}}>
-
+