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(database): edit reference cells as an @ mention in a text box (#9162)

Wolf Mermelstein20a540b25b4d
diff --git a/apps/web/src/features/database/components/grid-cell.preview.test.tsx b/apps/web/src/features/database/components/grid-cell.preview.test.tsx
index e7247dddeb..ee4a452180 100644
--- a/apps/web/src/features/database/components/grid-cell.preview.test.tsx
+++ b/apps/web/src/features/database/components/grid-cell.preview.test.tsx
@@ -58,9 +58,9 @@ it('keeps the current company preview mounted while searching and cancelling its
}) as HTMLInputElement;
expect(screen.getByTestId('company-preview')).toBe(original);
expect(disposals).toBe(0);
- expect(editor.value).toBe('');
+ expect(editor.value).toBe('@');
expect(document.activeElement).toBe(editor);
- fireEvent.input(editor, { target: { value: 'new company' } });
+ fireEvent.input(editor, { target: { value: '@new company' } });
expect(picker?.search).toBe('new company');
fireEvent.keyDown(editor, { key: 'Escape' });
await waitFor(() => expect(document.activeElement).toBe(trigger));
diff --git a/apps/web/src/features/database/components/grid-cell.tsx b/apps/web/src/features/database/components/grid-cell.tsx
index 2781715621..1d6f4d8e2e 100644
--- a/apps/web/src/features/database/components/grid-cell.tsx
+++ b/apps/web/src/features/database/components/grid-cell.tsx
@@ -203,7 +203,7 @@ export function GridCell(props: GridCellProps) {
setSelectedMention(undefined);
if (isEntity()) {
setMentionSearch(seed?.replace(/^@/, '') ?? '');
- setDraft(seed?.replace(/^@/, '') ?? '');
+ setDraft(`@${seed?.replace(/^@/, '') ?? ''}`);
setSelectAll(false);
setEditing(true);
setMentionOpen(true);
@@ -413,9 +413,7 @@ export function GridCell(props: GridCellProps) {
<div
class="grid"
inert={isEntity() && editing()}
- classList={{
- invisible: isEntity() && editing() && draft() !== '',
- }}
+ classList={{ invisible: isEntity() && editing() }}
>
<TextCell
column={props.column}
@@ -714,10 +712,6 @@ function InlineEditor(props: {
const [focused, setFocused] = createSignal(false);
const errorId = createUniqueId();
let finishing = false;
- const showingReference = () =>
- props.column.dataType === 'ENTITY' &&
- props.originalValue !== null &&
- props.draft === '';
// An earlier row's save can settle this column's type while this editor is
// focused. Keep its DOM for this edit; use the latest type when committing.
const renderTextEditor =
@@ -816,7 +810,7 @@ function InlineEditor(props: {
}}
type="text"
data-cell-text-editor
- placeholder={showingReference() ? undefined : props.emptyLabel}
+ placeholder={props.emptyLabel}
inputmode={
props.column.dataType === 'NUMBER' ? 'decimal' : undefined
}
@@ -838,11 +832,7 @@ function InlineEditor(props: {
if (!props.mentionOpen) commit(false);
}}
onKeyDown={onKeyDown}
- class="min-h-9 w-full min-w-0 px-2.5 py-1.5 text-[13px] text-ink outline-none"
- classList={{
- 'bg-transparent': !showingReference(),
- 'bg-transparent caret-transparent': showingReference(),
- }}
+ class="min-h-9 w-full min-w-0 bg-transparent px-2.5 py-1.5 text-[13px] text-ink outline-none"
/>
}
>