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: cmd+f hotkey for collapsed search state (#2582)

Peter Chinmand233246fafd4
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
index f714f1c6d4..aa77ea682c 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
@@ -85,6 +85,7 @@ export const SoupSearchbar = (props: SoupSearchbarProps) => {
const searchHotkey = registerHotkey({
hotkey: ['cmd+f'],
scopeId: panel.splitHotkeyScope,
+ registrationType: 'add',
description: 'Search',
keyDownHandler: () => {
editor.controls.focus();
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 7a5f0b7fbc..69ba97fb73 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
@@ -76,7 +76,7 @@ import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
import { useUserId } from '@core/context/user';
import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { SoupViewFileDropzone } from '@app/component/next-soup/soup-view/soup-view-file-dropzone';
-import { useHotkeyDOMScope } from '@core/hotkey/hotkeys';
+import { useHotkeyDOMScope, registerHotkey } from '@core/hotkey/hotkeys';
import { invalidateEntityNotifications } from '@queries/notification/user-notifications';
import type { CacheSnapshot } from 'virtua/unstable_core';
import { EmptyState } from '@app/component/next-soup/soup-view/empty-states';
@@ -211,6 +211,19 @@ export const SoupView = (props: SoupViewProps) => {
};
const [narrowSearchExpanded, setNarrowSearchExpanded] = createSignal(false);
+ const [searchIsCollapsed, setSearchIsCollapsed] = createSignal(false);
+
+ registerHotkey({
+ hotkey: 'cmd+f',
+ scopeId: panel.splitHotkeyScope,
+ registrationType: 'add',
+ description: 'Search',
+ keyDownHandler: () => {
+ if (narrowSearchExpanded() || !searchIsCollapsed()) return false;
+ setNarrowSearchExpanded(true);
+ return true;
+ },
+ });
const isMailView = createMemo(() => {
const content = panel.handle.content();
@@ -259,8 +272,8 @@ export const SoupView = (props: SoupViewProps) => {
<CollapsibleHeaderItem
id="tabs"
priority={1}
- expanded={<SoupViewTabs />}
- collapsed={<CollapsedSoupViewTabs />}
+ expanded={() => <SoupViewTabs />}
+ collapsed={() => <CollapsedSoupViewTabs />}
containerClass="h-full"
/>
</Show>
@@ -291,14 +304,15 @@ export const SoupView = (props: SoupViewProps) => {
id="search"
priority={0}
onCollapsedChange={(isCollapsed) => {
+ setSearchIsCollapsed(isCollapsed);
if (!isCollapsed) setNarrowSearchExpanded(false);
}}
- expanded={
+ expanded={() => (
<div class="w-52">
<SoupSearchbar variant="secondary" />
</div>
- }
- collapsed={
+ )}
+ collapsed={() => (
<Show when={!narrowSearchExpanded()}>
<Tooltip
tooltip={
@@ -314,7 +328,7 @@ export const SoupView = (props: SoupViewProps) => {
</Button>
</Tooltip>
</Show>
- }
+ )}
/>
</Show>
</SplitHeaderRight>
diff --git a/js/app/packages/app/component/split-layout/components/CollapsibleHeaderItem.tsx b/js/app/packages/app/component/split-layout/components/CollapsibleHeaderItem.tsx
index 0662b980cb..6bf24c7fed 100644
--- a/js/app/packages/app/component/split-layout/components/CollapsibleHeaderItem.tsx
+++ b/js/app/packages/app/component/split-layout/components/CollapsibleHeaderItem.tsx
@@ -5,8 +5,8 @@ import { cn } from '@ui/utils/classname';
type CollapsibleHeaderItemProps = {
id: string;
priority: number;
- expanded: JSX.Element;
- collapsed: JSX.Element;
+ expanded: () => JSX.Element;
+ collapsed: () => JSX.Element;
onCollapsedChange?: (isCollapsed: boolean) => void;
containerClass?: string;
};
@@ -32,7 +32,7 @@ export function CollapsibleHeaderItem(props: CollapsibleHeaderItemProps) {
ref={setExpandedRef}
class={cn('flex items-center', props.containerClass)}
>
- {props.expanded}
+ {props.expanded()}
</div>
</Show>
<Show when={isCollapsed()}>
@@ -40,7 +40,7 @@ export function CollapsibleHeaderItem(props: CollapsibleHeaderItemProps) {
ref={setCollapsedRef}
class={cn('flex items-center', props.containerClass)}
>
- {props.collapsed}
+ {props.collapsed()}
</div>
</Show>
</>
diff --git a/js/app/packages/block-channel/component/Top.tsx b/js/app/packages/block-channel/component/Top.tsx
index 1c6b612513..45a46d109c 100644
--- a/js/app/packages/block-channel/component/Top.tsx
+++ b/js/app/packages/block-channel/component/Top.tsx
@@ -117,7 +117,7 @@ export function ChannelTopLeft(props: ChannelTopLeftProps) {
id="channel-tabs"
priority={1}
containerClass="ph-no-capture min-w-0 shrink-0 h-full"
- expanded={
+ expanded={() => (
<Tabs
list={[...(props.tabs ?? [])]}
value={props.activeTab}
@@ -125,8 +125,8 @@ export function ChannelTopLeft(props: ChannelTopLeftProps) {
props.onTabChange?.(value as ChannelTabId)
}
/>
- }
- collapsed={
+ )}
+ collapsed={() => (
<Tabs
list={iconTabList()}
value={props.activeTab}
@@ -134,7 +134,7 @@ export function ChannelTopLeft(props: ChannelTopLeftProps) {
props.onTabChange?.(value as ChannelTabId)
}
/>
- }
+ )}
/>
</Show>
</Show>