Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(onboarding): keep focus on tutorial shell so hotkeys work immediately (#3698)

teo7852f02607c6
diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
index 1530cc7f10..63e9c37f18 100644
--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
@@ -239,9 +239,21 @@ function InteractiveOnboardingInner(props: InteractiveOnboardingProps) {
};
shellRef.addEventListener('keydown', stopKeyboardPropagation);
shellRef.addEventListener('keyup', stopKeyboardPropagation);
+
+ // Reclaim focus when it's dropped to <body> (null relatedTarget) so the
+ // scope stays active, but not while detaching — that's the close restore.
+ const reclaimLostFocus = (event: FocusEvent) => {
+ if (event.relatedTarget || commandKOpen() || !shellRef?.isConnected) {
+ return;
+ }
+ shellRef.focus();
+ };
+ shellRef.addEventListener('focusout', reclaimLostFocus);
+
onCleanup(() => {
shellRef?.removeEventListener('keydown', stopKeyboardPropagation);
shellRef?.removeEventListener('keyup', stopKeyboardPropagation);
+ shellRef?.removeEventListener('focusout', reclaimLostFocus);
});
}
});
diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx
index 73e3b69156..8b3e45a964 100644
--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboardingModal.tsx
@@ -1,3 +1,4 @@
+import { globalSplitManager } from '@app/signal/splitLayout';
import MacroLogo from '@core/component/MacroLogo';
import { isMobile } from '@core/mobile/isMobile';
import LogoIcon from '@icon/macro-logo.svg';
@@ -305,6 +306,14 @@ export function InteractiveOnboardingModal(
open={open()}
onOpenChange={setOpen}
position="center"
+ // Let the shell keep the focus it grabs in onMount (keeps its scope active).
+ onOpenAutoFocus={(e) => e.preventDefault()}
+ // Auto-opened on login, so Kobalte has nothing to restore to: return
+ // focus to the active split so the app stays keyboard-usable on close.
+ onCloseAutoFocus={(e) => {
+ e.preventDefault();
+ globalSplitManager()?.returnFocus();
+ }}
class="w-[min(1600px,calc(100vw-32px))] h-[min(900px,calc(100vh-32px))] max-w-none rounded-xl bg-surface shadow-2xl"
>
<div class="relative size-full overflow-hidden rounded-xl flex flex-col">