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: Rightbar focus issues (#1281)

Peter Chinman8706cf13ffbf
diff --git a/js/app/packages/app/component/rightbar/Rightbar.tsx b/js/app/packages/app/component/rightbar/Rightbar.tsx
index b9116648d6..f95d38a2ae 100644
--- a/js/app/packages/app/component/rightbar/Rightbar.tsx
+++ b/js/app/packages/app/component/rightbar/Rightbar.tsx
@@ -65,6 +65,7 @@ import {
onCleanup,
type Setter,
Show,
+ Suspense,
untrack,
} from 'solid-js';
import { SplitlikeContainer } from '../split-layout/components/SplitContainer';
@@ -352,27 +353,40 @@ export function Rightbar(props: {
}
};
- createEffect(() => {
- if (props.isBig) {
- borrowedFocus = document.activeElement;
- editor()?.focus();
- } else {
- if (untrack(isRightPanelOpen)) {
- return;
- } else {
- returnFocus();
- }
- }
- });
+ // Defering these effects so that they don't trigger on first load
+ createEffect(
+ on(
+ () => props.isBig,
+ (isBig) => {
+ if (isBig) {
+ borrowedFocus = document.activeElement;
+ editor()?.focus();
+ } else {
+ if (untrack(isRightPanelOpen)) {
+ return;
+ } else {
+ returnFocus();
+ }
+ }
+ },
+ { defer: true }
+ )
+ );
- createEffect(() => {
- if (isRightPanelOpen()) {
- borrowedFocus = document.activeElement;
- editor()?.focus();
- } else {
- returnFocus();
- }
- });
+ createEffect(
+ on(
+ isRightPanelOpen,
+ (isOpen) => {
+ if (isOpen) {
+ borrowedFocus = document.activeElement;
+ editor()?.focus();
+ } else {
+ returnFocus();
+ }
+ },
+ { defer: true }
+ )
+ );
return (
<DragDropWrapper
@@ -723,25 +737,27 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {
setSpotlight={setBigChatOpen}
tr={!bigChatOpen() && !settingsOpen()}
>
- <Rightbar
- chatId={chatId()}
- chatName={chatName()}
- messages={messages}
- onUnmount={getChatInputState}
- initialState={initialChatState()}
- onSend={onSend}
- stream={stream}
- stopGenerating={stopGenerating}
- setState={{
- setChatId,
- setModel,
- setAttachments,
- setText,
- setMessages,
- setStream,
- }}
- isBig={bigChatOpen()}
- />
+ <Suspense>
+ <Rightbar
+ chatId={chatId()}
+ chatName={chatName()}
+ messages={messages}
+ onUnmount={getChatInputState}
+ initialState={initialChatState()}
+ onSend={onSend}
+ stream={stream}
+ stopGenerating={stopGenerating}
+ setState={{
+ setChatId,
+ setModel,
+ setAttachments,
+ setText,
+ setMessages,
+ setStream,
+ }}
+ isBig={bigChatOpen()}
+ />
+ </Suspense>
</SplitlikeContainer>
</div>
</Resize.Panel>