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: make focus first entity reactive (#1569)

gbirman42af05b79af2
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index f382b50ef6..0eea2f59d0 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -200,28 +200,36 @@ export const SoupViewList = (props: SoupViewListProps) => {
}
};
+ const [focusEffectsEnabled, setFocusEffectsEnabled] = createSignal(false);
+ const [moveInitialFocus, setMoveInitialFocus] = createSignal(true);
+
let initialLoad = true;
- const registerFocusEffects = (moveInitialFocus = true) => {
- if (moveInitialFocus) {
- createEffect(
- on(rows, () => {
- if (!initialLoad || source.isLoading()) return;
- focusFirstEntity();
- initialLoad = false;
- })
- );
- }
+ // Initial load: focus first entity once rows arrive
+ createEffect(
+ on(rows, () => {
+ if (!focusEffectsEnabled() || !moveInitialFocus()) return;
+ if (!initialLoad || source.isLoading()) return;
+ focusFirstEntity();
+ initialLoad = false;
+ })
+ );
+
+ // Focus first entity on filter/search changes
+ createEffect(
+ on(
+ () => [soup.filters.activeIds(), searchText(), featuredIds()] as const,
+ () => {
+ if (!focusEffectsEnabled()) return;
+ focusFirstEntity();
+ },
+ { defer: true }
+ )
+ );
- createEffect(
- on(
- () => [soup.filters.activeIds(), searchText(), featuredIds()] as const,
- () => {
- focusFirstEntity();
- },
- { defer: true }
- )
- );
+ const registerFocusEffects = (shouldMoveInitialFocus = true) => {
+ setMoveInitialFocus(shouldMoveInitialFocus);
+ setFocusEffectsEnabled(true);
};
const previewPanel = useMaybePreviewPanel();