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.

feat(soup): bind collapse/expand hotkeys to group-by sections (#3707)

gbirman7bf93e92aa19
diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts
index 16d3a2788f..9ff08ecb87 100644
--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-navigation-hotkeys.ts
@@ -189,18 +189,43 @@ export const useSoupNavigationHotkeys = (
) as HTMLButtonElement | null;
};
+ // When the focused row is a group header, drive it toward `targetExpanded`.
+ // Returns true if it toggled, false if already in that state, or undefined
+ // when the focused row isn't a group header so the caller can fall through.
+ const toggleFocusedGroupHeader = (
+ targetExpanded: boolean
+ ): boolean | undefined => {
+ const focusedRow = soup.focus.row();
+ if (!focusedRow?.getIsGrouped() || !focusedRow.group) return undefined;
+ if (focusedRow.group.isExpanded() === targetExpanded) return false;
+ focusedRow.group.toggle();
+ return true;
+ };
+
registerHotkey({
hotkey: ['h', 'arrowleft'],
scopeId,
description: 'Collapse item',
hotkeyToken: TOKENS.unifiedList.navigation.parent,
keyDownHandler: () => {
+ const groupHandled = toggleFocusedGroupHeader(false);
+ if (groupHandled !== undefined) return groupHandled;
+
const toggle = getCollapsibleToggle();
if (toggle?.dataset.collapsibleState === 'expanded') {
toggle.click();
return true;
}
+ // From a child row, collapse its parent group and focus the header.
+ const focusedGroup = soup.focus.row()?.group;
+ if (focusedGroup?.isExpanded()) {
+ focusedGroup.toggle();
+ const header = soup.navigate.toId(`header:${focusedGroup.key}`);
+ if (header) scrollTo(header.index);
+ return true;
+ }
+
return false;
},
registrationType: 'add',
@@ -214,6 +239,9 @@ export const useSoupNavigationHotkeys = (
description: 'Expand item',
hotkeyToken: TOKENS.unifiedList.navigation.child,
keyDownHandler: () => {
+ const groupHandled = toggleFocusedGroupHeader(true);
+ if (groupHandled !== undefined) return groupHandled;
+
const toggle = getCollapsibleToggle();
if (toggle?.dataset.collapsibleState === 'collapsed') {
toggle.click();