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: expand and collapse search state (#1551)

gbirman1b3b162af2f6
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 be3b56946d..c995f7444b 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
@@ -171,12 +171,28 @@ export const useSoupNavigationHotkeys = (
const previewPanel = useMaybePreviewPanel();
+ const getCollapsibleToggle = () => {
+ const focusedId = soup.focus.id();
+ if (!focusedId) return undefined;
+ const entityEl = document.querySelector(`[data-entity-id="${focusedId}"]`);
+ if (!entityEl) return undefined;
+ return entityEl.querySelector(
+ 'button[data-collapsible-toggle]'
+ ) as HTMLButtonElement | null;
+ };
+
registerHotkey({
hotkey: ['h', 'arrowleft'],
scopeId,
description: 'Navigate to parent context',
hotkeyToken: TOKENS.unifiedList.navigation.parent,
keyDownHandler: () => {
+ const toggle = getCollapsibleToggle();
+ if (toggle?.dataset.collapsibleState === 'expanded') {
+ toggle.click();
+ return true;
+ }
+
if (!previewPanel) return false;
previewPanel.onFocusOut();
@@ -194,6 +210,12 @@ export const useSoupNavigationHotkeys = (
description: 'Navigate to child context',
hotkeyToken: TOKENS.unifiedList.navigation.child,
keyDownHandler: () => {
+ const toggle = getCollapsibleToggle();
+ if (toggle?.dataset.collapsibleState === 'collapsed') {
+ toggle.click();
+ return true;
+ }
+
const previewPanelContent = options.previewPanelRef();
// If there is no preview or the preview already contains focus, skip
if (
diff --git a/js/app/packages/entity/src/components/CollapsibleList.tsx b/js/app/packages/entity/src/components/CollapsibleList.tsx
index e73daa1b61..84e13c69d7 100644
--- a/js/app/packages/entity/src/components/CollapsibleList.tsx
+++ b/js/app/packages/entity/src/components/CollapsibleList.tsx
@@ -76,6 +76,8 @@ export function CollapsibleList<T>(props: CollapsibleListProps<T>) {
<button
type="button"
class="flex items-center gap-1 text-xs bracket-never hover:text-accent"
+ data-collapsible-toggle
+ data-collapsible-state={showAll() ? 'expanded' : 'collapsed'}
onClick={(e) => {
e.stopPropagation();
setShowAll((prev) => !prev);