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(databases): rename titles from double-click and the menu (#8998)

Wolf Mermelsteinfd5ab9ede76f
diff --git a/apps/web/src/components/app/split-layout/components/SplitLabel.tsx b/apps/web/src/components/app/split-layout/components/SplitLabel.tsx
index 1433625c46..c50484afb6 100644
--- a/apps/web/src/components/app/split-layout/components/SplitLabel.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitLabel.tsx
@@ -311,7 +311,7 @@ export function BlockItemSplitLabel(props: {
</Show>
}
>
- {props.title}
+ {(title) => title()}
</Show>
{props.trailingBadges}
<div
diff --git a/apps/web/src/features/block-database/views/database-page-actions.test.tsx b/apps/web/src/features/block-database/views/database-page-actions.test.tsx
index cdde20683c..4b250fcf53 100644
--- a/apps/web/src/features/block-database/views/database-page-actions.test.tsx
+++ b/apps/web/src/features/block-database/views/database-page-actions.test.tsx
@@ -1,3 +1,4 @@
+import { BlockItemSplitLabel } from '@components/app/split-layout/components/SplitLabel';
import type { DatabaseDetail } from '@service-storage/generated/schemas/databaseDetail';
import type { TableDetail } from '@service-storage/generated/schemas/tableDetail';
import {
@@ -9,6 +10,7 @@ import {
within,
} from '@solidjs/testing-library';
import { errAsync, okAsync, type ResultAsync } from 'neverthrow';
+import { createSignal, Show } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { toast } from '../../../lib/core/component/Toast/Toast';
import { DatabaseTitle } from '../../database/components/database-title';
@@ -18,6 +20,31 @@ import {
DatabasePageActions,
} from './database-page-actions';
+// Keep the real split label, title and menu together; stub only host data.
+vi.mock('@app/components/entity-detail/DocumentTitleHoverCard', () => ({
+ DocumentTitleHoverCard: () => null,
+}));
+vi.mock('@core/block', () => ({
+ isInBlock: () => true,
+ useBlockAliasedName: () => 'database',
+}));
+vi.mock('@core/component/EntityIcon', () => ({ EntityIcon: () => null }));
+vi.mock('@core/signal/load', () => ({ blockMetadataSignal: () => undefined }));
+vi.mock('@core/signal/permissions', () => ({
+ useIsDocumentOwner: () => () => true,
+}));
+vi.mock('@core/util/currentBlockDocumentName', () => ({
+ useBlockDocumentName: () => () => 'Customers',
+}));
+vi.mock('@components/app/split-layout/layoutUtils', () => ({
+ useSplitDisplayName: () => {},
+ useSplitPanelOrThrow: () => ({
+ titleFileMenuActions: () => undefined,
+ titleFileMenuTrigger: () => undefined,
+ setTitleFileMenuRef: () => {},
+ }),
+}));
+
const mocks = vi.hoisted(() => ({
download: vi.fn(),
csv: vi.fn(),
@@ -56,13 +83,24 @@ function setup(
entityActions?: DatabaseEntityActions
) {
let editTitle: (() => void) | undefined;
+ const editReady = vi.fn((edit: (() => void) | undefined) => {
+ editTitle = edit;
+ });
+ const [loaded, setLoaded] = createSignal(false);
render(() => (
<>
- <DatabaseTitle
- name="Customers"
- canEdit={grant !== 'view'}
- onRename={vi.fn()}
- onEditReady={(edit) => (editTitle = edit)}
+ <BlockItemSplitLabel
+ name={() => 'Customers'}
+ title={
+ <Show when={loaded()}>
+ <DatabaseTitle
+ name="Customers"
+ canEdit={grant !== 'view'}
+ onRename={vi.fn()}
+ onEditReady={editReady}
+ />
+ </Show>
+ }
/>
<DatabasePageActions
detail={
@@ -80,7 +118,8 @@ function setup(
/>
</>
));
- return { remove };
+ setLoaded(true);
+ return { remove, editReady };
}
async function openMenu() {
const trigger = screen.getByRole('button', { name: 'Database actions' });
@@ -96,7 +135,8 @@ function selectItem(name: string) {
describe('database page actions', () => {
it('focuses the inline title from Rename', async () => {
- setup();
+ const { editReady } = setup();
+ expect(editReady).toHaveBeenCalledTimes(1);
expect(screen.queryByRole('button', { name: 'Import CSV' })).toBeNull();
expect(
screen.queryByRole('button', { name: 'Download database' })
diff --git a/apps/web/src/features/database/components/database-title.test.tsx b/apps/web/src/features/database/components/database-title.test.tsx
index 3b10d04b27..8bd75d6636 100644
--- a/apps/web/src/features/database/components/database-title.test.tsx
+++ b/apps/web/src/features/database/components/database-title.test.tsx
@@ -7,15 +7,18 @@ afterEach(cleanup);
function setup(name = 'Untitled database', canEdit = true) {
let edit: (() => void) | undefined;
const rename = vi.fn();
+ const parentDoubleClick = vi.fn();
render(() => (
- <DatabaseTitle
- name={name}
- canEdit={canEdit}
- onRename={rename}
- onEditReady={(start) => (edit = start)}
- />
+ <div onDblClick={parentDoubleClick}>
+ <DatabaseTitle
+ name={name}
+ canEdit={canEdit}
+ onRename={rename}
+ onEditReady={(start) => (edit = start)}
+ />
+ </div>
));
- return { rename, edit: () => edit?.() };
+ return { rename, parentDoubleClick, edit: () => edit?.() };
}
describe('database title', () => {
@@ -37,6 +40,16 @@ describe('database title', () => {
expect(input.selectionEnd).toBe('Untitled database'.length);
});
+ it('focuses and selects the current name on double-click without opening the header menu', () => {
+ const { parentDoubleClick } = setup('Projects');
+ fireEvent.dblClick(screen.getByText('Projects'));
+ const input = screen.getByRole('textbox') as HTMLInputElement;
+ expect(document.activeElement).toBe(input);
+ expect(input.selectionStart).toBe(0);
+ expect(input.selectionEnd).toBe('Projects'.length);
+ expect(parentDoubleClick).not.toHaveBeenCalled();
+ });
+
it('saves on Enter and returns to a static label', () => {
const { rename, edit } = setup();
edit();
@@ -76,6 +89,7 @@ describe('database title', () => {
it('keeps the title read-only without edit access', () => {
const { edit } = setup('Shared database', false);
edit();
+ fireEvent.dblClick(screen.getByText('Shared database'));
expect(screen.getByText('Shared database')).toBeTruthy();
expect(screen.queryByRole('textbox')).toBeNull();
});
diff --git a/apps/web/src/features/database/components/database-title.tsx b/apps/web/src/features/database/components/database-title.tsx
index 5e86eb1605..3f7ac971e8 100644
--- a/apps/web/src/features/database/components/database-title.tsx
+++ b/apps/web/src/features/database/components/database-title.tsx
@@ -9,22 +9,32 @@ export function DatabaseTitle(props: {
onRename: (name: string) => void;
}) {
const [editing, setEditing] = createSignal(false);
- onMount(() =>
- props.onEditReady?.(() => {
- if (props.canEdit) setEditing(true);
- })
- );
+ const startEditing = () => {
+ if (props.canEdit) setEditing(true);
+ };
+ onMount(() => props.onEditReady?.(startEditing));
onCleanup(() => props.onEditReady?.(undefined));
return (
<Show
when={props.canEdit && editing()}
fallback={
- <span class="inline-block truncate text-sm font-semibold">
+ <span
+ class="inline-block truncate text-sm font-semibold"
+ onDblClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ startEditing();
+ }}
+ >
{props.name}
</span>
}
>
- <span class="flex min-w-0">
+ <span
+ class="flex min-w-0"
+ onClick={(event) => event.stopPropagation()}
+ onDblClick={(event) => event.stopPropagation()}
+ >
<InlineTitleEditor
value={props.name}
placeholder="Untitled database"
diff --git a/docs/agent-guide/databases.md b/docs/agent-guide/databases.md
index 6987cd2d45..1264bfe329 100644
--- a/docs/agent-guide/databases.md
+++ b/docs/agent-guide/databases.md
@@ -18,11 +18,13 @@ Databases open at
`/app/database/<uuid>`; from Drive (its list, favorites, or **New → Database**)
they open inline at `/app/drive/database/<uuid>` with Drive's sidebar in place.
A database contains tables; records belong to a table and
-its properties describe each record. The database name in the split header is an
-static label, matching other blocks. Choose **Rename** in Database actions to
-edit it. Enter or leaving the input saves and closes it; Escape cancels. Saving
-a title does not enter the grid, and a failed rename shows a toast. Viewers without edit access see the
-split header's `viewer` badge instead.
+its properties describe each record. The database name in the split header is a
+static label until edited. Double-click it or choose **Rename** in Database actions
+to edit the same inline title with the current name selected. On touch devices,
+use **Database actions → Rename**. Enter or leaving the input saves and closes it; Escape cancels. Saving
+a title does not enter the grid, and a failed rename shows a toast. Reload to verify
+the saved name persists. Viewers cannot enter rename from either entry point and
+see the split header's `viewer` badge instead.
Reopening a loaded table or view shows its cached rows while a background read
checks for changes. Wait for refreshing to finish before asserting server