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(mentions): keep bin headers steady when View all disappears (#8224)

teo820a4b16fed5
diff --git a/apps/web/knip.ts b/apps/web/knip.ts
index ee74cfa08d..5346241e47 100644
--- a/apps/web/knip.ts
+++ b/apps/web/knip.ts
@@ -12,6 +12,7 @@ const config: KnipConfig = {
// Feature browser harnesses load from their own HTML and Playwright specs.
'src/features/*/browser-test/*.{ts,tsx}',
'src/lib/core/component/LexicalMarkdown/component/decorator/browser-test/*.tsx',
+ 'src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/*.{ts,tsx}',
'src/features/billing-lab/entry.tsx',
// Native test runners are invoked by scripts, not the application graph.
'tests/native/{runner,links-runner,notifications-runner}.ts',
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.browser.e2e.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.browser.e2e.ts
new file mode 100644
index 0000000000..7fbebab27e
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.browser.e2e.ts
@@ -0,0 +1,26 @@
+import { expect, test } from '@playwright/test';
+
+test('filtering away View all keeps the bin header and rows in place', async ({
+ page,
+}) => {
+ await page.goto(
+ '/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.html'
+ );
+ const label = page.getByText('People', { exact: true });
+ const firstRow = page.getByText('Ada Lovelace', { exact: true });
+ await expect(page.getByRole('button', { name: 'View all (5)' })).toBeVisible({
+ timeout: 30_000,
+ });
+ const before = [
+ (await label.boundingBox())?.y,
+ (await firstRow.boundingBox())?.y,
+ ];
+
+ await page.getByLabel('Search people').fill('ada');
+ await expect(page.getByRole('button', { name: /View all/ })).toHaveCount(0);
+
+ expect([
+ (await label.boundingBox())?.y,
+ (await firstRow.boundingBox())?.y,
+ ]).toEqual(before);
+});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.html b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.html
new file mode 100644
index 0000000000..216b77fa39
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<html lang="en">
+ <head><meta charset="UTF-8"><title>Mentions menu bin fixture</title></head>
+ <body><div id="root"></div><script type="module" src="./item-bin.tsx"></script></body>
+</html>
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.tsx
new file mode 100644
index 0000000000..78dc72ac36
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/item-bin.tsx
@@ -0,0 +1,49 @@
+import '@app/index.css';
+import { Surface } from '@ui';
+import { createSignal, For } from 'solid-js';
+import { render } from 'solid-js/web';
+import { ItemBin } from '../components/ItemBin';
+
+const people = [
+ 'Ada Lovelace',
+ 'Alan Turing',
+ 'Grace Hopper',
+ 'Linus Torvalds',
+ 'Margaret Hamilton',
+];
+const shownPerBin = 3;
+
+function Fixture() {
+ const [search, setSearch] = createSignal('');
+ const matches = () =>
+ people.filter((name) =>
+ name.toLowerCase().includes(search().toLowerCase())
+ );
+ return (
+ <main class="p-4 text-ink bg-page space-y-4">
+ <input
+ aria-label="Search people"
+ value={search()}
+ onInput={(event) => setSearch(event.currentTarget.value)}
+ />
+ <Surface
+ depth={2}
+ class="w-96 pt-2 pb-1.5 glass bg-menu-glass rounded-xl"
+ >
+ <ItemBin
+ label="People"
+ binType="users"
+ totalCount={matches().length}
+ showingCount={Math.min(matches().length, shownPerBin)}
+ onViewAll={() => {}}
+ >
+ <For each={matches().slice(0, shownPerBin)}>
+ {(name) => <div class="flex h-9 items-center px-2">{name}</div>}
+ </For>
+ </ItemBin>
+ </Surface>
+ </main>
+ );
+}
+
+render(() => <Fixture />, document.getElementById('root')!);
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/playwright.config.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/playwright.config.ts
new file mode 100644
index 0000000000..ad0ed6aff1
--- /dev/null
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/browser-test/playwright.config.ts
@@ -0,0 +1,29 @@
+import { fileURLToPath } from 'node:url';
+import { defineConfig } from '@playwright/test';
+
+const webDirectory = fileURLToPath(
+ new URL('../../../../../../../../../', import.meta.url)
+);
+const port = process.env.MENTIONS_MENU_TEST_PORT ?? '3048';
+
+export default defineConfig({
+ testDir: fileURLToPath(new URL('.', import.meta.url)),
+ testMatch: '*.browser.e2e.ts',
+ workers: 1,
+ timeout: 60_000,
+ use: {
+ baseURL: `http://localhost:${port}`,
+ headless: true,
+ viewport: { width: 1280, height: 800 },
+ launchOptions: {
+ executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
+ },
+ },
+ webServer: {
+ command: `MACRO_DEV_HTTPS=false bunx vite --port ${port} --strictPort`,
+ cwd: webDirectory,
+ url: `http://localhost:${port}/app/`,
+ reuseExistingServer: false,
+ timeout: 60_000,
+ },
+});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/ItemBin.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/ItemBin.tsx
index 199f4589c0..4c53a38e4c 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/ItemBin.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/components/ItemBin.tsx
@@ -49,7 +49,7 @@ export function ItemBin(
<Show when={showViewAllButton()}>
<button
type="button"
- class="inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md px-1.5 text-xs font-normal text-ink-muted outline-none hover:bg-hover hover:text-ink focus-visible:ring-1 focus-visible:ring-ink/30"
+ class="-my-1 inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md px-1.5 text-xs font-normal text-ink-muted outline-none hover:bg-hover hover:text-ink focus-visible:ring-1 focus-visible:ring-ink/30"
aria-keyshortcuts={props.isSelected ? 'ArrowRight' : undefined}
onMouseDown={(e) => {
e.preventDefault();