test(ai-toolbar): verify paste listener gating at component boundary
This commit is contained in:
@@ -94,22 +94,6 @@ interface AIToolbarProps {
|
||||
events: CalendarEvent[];
|
||||
}
|
||||
|
||||
interface GlobalPasteCaptureGate {
|
||||
isAuthenticated: boolean;
|
||||
isPending: boolean;
|
||||
canUseAi: boolean;
|
||||
aiLoading: boolean;
|
||||
}
|
||||
|
||||
export function shouldEnableGlobalPasteCapture({
|
||||
isAuthenticated,
|
||||
isPending,
|
||||
canUseAi,
|
||||
aiLoading,
|
||||
}: GlobalPasteCaptureGate): boolean {
|
||||
return isAuthenticated && !isPending && canUseAi && !aiLoading;
|
||||
}
|
||||
|
||||
// ─── Component ────────────────────────────────────────────────────────────────
|
||||
|
||||
export const AIToolbar = ({
|
||||
@@ -170,14 +154,7 @@ export const AIToolbar = ({
|
||||
// focused element or OS clipboard model (X11/Wayland).
|
||||
// This is the approach used by Excalidraw's actionPaste.
|
||||
useEffect(() => {
|
||||
if (
|
||||
!shouldEnableGlobalPasteCapture({
|
||||
isAuthenticated,
|
||||
isPending,
|
||||
canUseAi,
|
||||
aiLoading,
|
||||
})
|
||||
)
|
||||
if (!(isAuthenticated && !isPending && canUseAi && !aiLoading))
|
||||
return;
|
||||
|
||||
// ── Handler 1: paste event (works when textarea is NOT focused) ───────
|
||||
|
||||
Reference in New Issue
Block a user