Skip to content

Commit a58e9fc

Browse files
committed
WIP using onModalClose
1 parent 249b70b commit a58e9fc

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

apps/webapp/app/components/navigation/HelpAndFeedbackPopover.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import { Popover, PopoverContent, PopoverSideMenuTrigger } from "../primitives/P
2323
import { StepNumber } from "../primitives/StepNumber";
2424
import { MenuCount, SideMenuItem } from "./SideMenuItem";
2525
import { Shortcuts } from "../Shortcuts";
26-
export function HelpAndFeedback() {
26+
27+
export function HelpAndFeedback({ disableShortcut = false }: { disableShortcut?: boolean }) {
2728
const [isHelpMenuOpen, setHelpMenuOpen] = useState(false);
2829
const currentPlan = useCurrentPlan();
2930

@@ -33,6 +34,7 @@ export function HelpAndFeedback() {
3334
isOpen={isHelpMenuOpen}
3435
shortcut={{ key: "h", enabledOnInputElements: false }}
3536
className="grow pr-2"
37+
disabled={disableShortcut}
3638
>
3739
<div className="flex items-center gap-1.5">
3840
<QuestionMarkCircleIcon className="size-4 text-success" />

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ function SelectorDivider() {
547547
}
548548

549549
function HelpAndAI() {
550+
const [isKapaOpen, setIsKapaOpen] = useState(false);
550551
const features = useFeatures();
551552
const kapa = useKapa();
552553

@@ -555,10 +556,16 @@ function HelpAndAI() {
555556

556557
loadScriptIfNotExists(kapa.websiteId);
557558

559+
// Define the handler function
560+
const handleModalClose = () => {
561+
setIsKapaOpen(false);
562+
};
563+
558564
const kapaInterval = setInterval(() => {
559565
if (typeof window.Kapa === "function") {
560566
clearInterval(kapaInterval);
561567
window.Kapa("render");
568+
window.Kapa("onModalClose", handleModalClose);
562569
}
563570
}, 100);
564571

@@ -573,7 +580,7 @@ function HelpAndAI() {
573580

574581
return (
575582
<>
576-
<HelpAndFeedback />
583+
<HelpAndFeedback disableShortcut={isKapaOpen} />
577584
<TooltipProvider disableHoverableContent>
578585
<Tooltip>
579586
<TooltipTrigger asChild>
@@ -587,6 +594,7 @@ function HelpAndAI() {
587594
onClick={() => {
588595
if (typeof window.Kapa === "function") {
589596
window.Kapa("open");
597+
setIsKapaOpen(true);
590598
}
591599
}}
592600
>

apps/webapp/app/root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { useTypedMatchesData } from "./hooks/useTypedMatchData";
2828

2929
declare global {
3030
interface Window {
31-
Kapa: (command: string, options?: { onRender?: () => void }) => void;
31+
Kapa: (command: string, options?: (() => void) | { onRender?: () => void }) => void;
3232
}
3333
}
3434

0 commit comments

Comments
 (0)