Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(notebooks): bolder cell titles that collapse the cell on click (#72836)

Sinan Kucukkoselerab2aec1c901b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 1c7bd8e2e5fe..6b5d9df6a6e3 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1201,17 +1201,17 @@ snapshots:
components-markdown-editor-rich--with-markdown--light:
hash: v1.k794b7964.98bef7667e05e7a86864149a5db5c24b3d4733bcef7d413ab6faf3053c79fba8.evR63xGwLPTzXw6Hi35ROggl2AHmH_y5lT5p05kFGTg
components-markdown-notebook--component-catalog--dark:
- hash: v1.k794b7964.d10cdaf736d7fb570e1de84cd16ac08c7b77c01a0e83786c53be114a1920b14b.wMTKlaMcPVf2Oa-7SW-MJMWfCleINO7H7UMVBuNZx4o
+ hash: v1.k794b7964.c1195f4ea82d9c4e1c781e507bed8cb4f09526b6574099646b271245e65e2022.1mSVdYQnM-zC2d-82S3X4zhsChvArz9rNmSBDdfZNZE
components-markdown-notebook--component-catalog--light:
- hash: v1.k794b7964.fa6713fc43b5ac737cd4cc73ff4ac028b616274e6830d913f6f5a5c16d1d469a.ZeWXazLxfRnmlDnsZ8iIdwpuBmZ9pV3OvYcj53aylz4
+ hash: v1.k794b7964.5739bda1024b64e13d93d1a8367101f6a1467ab053554b520ba37eba0b27068e.b_39_EGipiHnNS16kzBL4tPy4qoB-ktDllOZy0B2HvM
components-markdown-notebook--edit-mode--dark:
- hash: v1.k794b7964.d10cdaf736d7fb570e1de84cd16ac08c7b77c01a0e83786c53be114a1920b14b.VKobiY_K74yfeprxC7FWq4woMYWlu97oTiKJ6uRgqzA
+ hash: v1.k794b7964.75e68a67c0e1055d31d9ec97d48a01e991a971dc1d4169e810d49f09d7dd8dd9.s6xiwDf7dhx9bIE3p4FdovsjEQnrGtDXzRD8lJmHy90
components-markdown-notebook--edit-mode--light:
- hash: v1.k794b7964.fa6713fc43b5ac737cd4cc73ff4ac028b616274e6830d913f6f5a5c16d1d469a.QyW7DBWe_DqngerbDq8rZ7gapgUgeaZBrJBjCEk9r5s
+ hash: v1.k794b7964.70359adcd7402800180983f982617fa3fc0f19edb5e52b14271c94527d51eed6.hr5Der5LQuhmqCgMsD3fHCbeQvzgvoZ7cvbhduHjgcs
components-markdown-notebook--embeds--dark:
- hash: v1.k794b7964.d816244856d560db462b36a15bceb7eab27f15d645153194cda95c2617f70d17.klscu9iABK77cx728RBGDF4vg6RCDx6ebaJ3GKLTyKU
+ hash: v1.k794b7964.666a1ab6a3279f149b4cf0f83265b64d484a8fd9ce21534b2997ed385d9fd8dc.pjdMc0yeqb9tATSP6Lrf5IP1ekkvKDv_U57c4URmmWM
components-markdown-notebook--embeds--light:
- hash: v1.k794b7964.a69654947285c8dd665a7a1ce0a61e86fe38a7c53877f6ac13690c0b8c8e97e2.4kJJ0Vuk7JD2zn8mz4hzNUX2vCTUJ2A9i9CmAvaJKGY
+ hash: v1.k794b7964.231ca120286f24dbff92195655a747efe5c409da15a11bd848a8c25098321708.nD6Sf2SUy4runSGLLjl2hbmS5cUJwwsfde2nIkUfPXU
components-markdown-notebook--empty-notebook--dark:
hash: v1.k794b7964.8eead993034f2c49605117d1209d49eba6232f18509f28c36a11583c83a06c95.uNfIEuJu7VxEaywegw-eDdV7uZMCQrkGaRFqcexDrA0
components-markdown-notebook--empty-notebook--light:
@@ -1221,9 +1221,9 @@ snapshots:
components-markdown-notebook--headings-and-inline-formatting--light:
hash: v1.k794b7964.38e87809a617b9d678891017ee6e78752effcf948b97ec7568efb71ac24bcf6a.xT83tL3e33wxruaCJlSjvTaBSjbK1zSX0Pif21pHkcM
components-markdown-notebook--invalid-component-props--dark:
- hash: v1.k794b7964.30cd80f0410a7889cbc45215eda61419c7a3ce82de1604d740c3bc1de44dc282.nyhvdDRy-XLY62Q1sx0EYc8XJVksmPB8ytxhdpGqGII
+ hash: v1.k794b7964.8ba512a554ed7dd8dc46e094992c1aa5311bcbe270db6487080c2ab3470d2cea.OByuS6edqSKSnB9tlHTlFOOqesQ6fi0-JvsmMWX66yM
components-markdown-notebook--invalid-component-props--light:
- hash: v1.k794b7964.ac17f414d4282c20f1e46045ea462daf7a19d1f263e0b58b43cb361fe0a8f837.viC6Gm37TpC2-P2sA2U-RDFTyEDTlpb8Ohz6NbsScj0
+ hash: v1.k794b7964.4cab15d219d1f1989ec25b36bb0037097efa2dd651e0380ae9c8daeb799486dd.E6fa6X5W9THi_EqqDbMrpaYwAUjsLKKrztCRL3NwMsw
components-markdown-notebook--lists-and-links--dark:
hash: v1.k794b7964.bbd83d85a0585d1a3428678151002e6b4da9084256f41ac239250ddb831321f6.W43uC9ABBUVWperGNIuAeXNp9AR4iCQH04kfwJktkbg
components-markdown-notebook--lists-and-links--light:
@@ -1249,9 +1249,9 @@ snapshots:
components-markdown-notebook--mocked-collaboration--light:
hash: v1.k794b7964.5b0d52dc1eb8dd9f9906108308093d1e3f477b9f671027f613581e65f11738a4.izBrg-kCKLfpYBm77YuQe5SqULcKK8EmsVgz-P6M_kY
components-markdown-notebook--query-block--dark:
- hash: v1.k794b7964.23fbb2d58c49d9814ba7b0b2871b74c4137f6c9e08ab156f18518486d74b7d2d.sYNuVPko_KEt3CMfqanmApZoMemXcEqJp8r84cApET4
+ hash: v1.k794b7964.9462b3e1e5303a27a5ba68940abb6a6b53c3ca6a6e7b7f6f3ebf80ba4c18eaeb.aqQJOmyCIGUyTzQ1NQS9dmQXWEu_G7YOxSCCvR-YS6M
components-markdown-notebook--query-block--light:
- hash: v1.k794b7964.542756ac4f9718c3bdc61ee6f0291d14d8703c410c6bf109bb5f810c243c5971.gBJlecXaoFfCxi98-5Yplx-kMcB4kr4X2H4ng9jMXMw
+ hash: v1.k794b7964.c7d938594b2adf78b1cb2b6b06502edd842701026e8e3b0014e6bd2571701ae5._HYTts0_d2ety-dJS140Adz40WvojQghhEJg-T4JwBI
components-markdown-notebook--selection-toolbar-state--dark:
hash: v1.k794b7964.3ae4e75244d0227c7e592b7937380ee3ff8e94a5cafa2b05cb49c5ef9cad727a.j7qvSpyDubygwc7VsU2sbliJbjCKR9EwWvoay5j5e2c
components-markdown-notebook--selection-toolbar-state--light:
@@ -1265,9 +1265,9 @@ snapshots:
components-markdown-notebook--text-only-notebook--light:
hash: v1.k794b7964.fef48fc6ed9f1349a5d8fb7e988c301515d4623dfd68c2b55502f33d1e511dd8.uIPJinERIkOO-F9dYe_C102CBZ1nb51hWeQpx7z8zGU
components-markdown-notebook--view-mode--dark:
- hash: v1.k794b7964.b9116563489f1db7495d3e1676283ceeb1aef9ad26023388700ca0cbca160de2.H3d4eR3Jxons0bpMo77HZ0pkdARVvI7LuRXjgyQaisI
+ hash: v1.k794b7964.7af7b745d77758ee42b42bf785db8a100f23ff01003dad9772c6a1c99c43faf4.Iv3JhJK0ubvLu9eFH6ft2ai5-VYWLzAiQD2HIKo_RJE
components-markdown-notebook--view-mode--light:
- hash: v1.k794b7964.2056cc9a9fd58377e87c551af21116cf7f47e09de6046f3325002b6ddfdb1db5.0zZLIPF-GLHi8i-pxBp66F8W0H710sFaLebxWziFB8I
+ hash: v1.k794b7964.11c2bd01a8840cb7147eb94693398331ab96b2dffc7fc049a5bf021fdef421e1.3HlB3wcmf1v_k83nyNus_piIMHd3_PwM9kun-EqTRgY
components-mcp-hint-toast--annotations-create--dark:
hash: v1.k794b7964.a89a0112c0a5202091776711f4eb89de90f847e3a687d64af45d0fac54d628a6.v-Uh8HnxDI3DUFmLjo_4pXl43CUBzowOuqUNyLZcnHg
components-mcp-hint-toast--annotations-create--light:
@@ -6499,9 +6499,9 @@ snapshots:
scenes-app-notebooks--numbered-list--light:
hash: v1.k794b7964.a7c359b0c62468903ee153f7d554332ffb23ddeb5823f8772cbbc9bdda85ef39.vqBNXyRaDc-oPTu-JlCeXZXDW3hlVysSsDe1vCbkFbk
scenes-app-notebooks--recordings-playlist--dark:
- hash: v1.k794b7964.bf39c6b292425894510288542c473b5d926f648af56fb9ee305715c560c06f86.rvD4Bs7KFJXywUr9a7FeSgzuIijEfgvh7EYIEBk3C8w
+ hash: v1.k794b7964.99878e1bbb2038170b53e000ee0268c2fc5dea97c6a9c803b3646eac13b1b570.n5KKoXyCYJ5EEweg66zzEI0cUM4cO5PgKN9X4haYLo0
scenes-app-notebooks--recordings-playlist--light:
- hash: v1.k794b7964.c0528384e510106068f1ec51cc84d089e229266f1af6913a7476f5072f834735.p9LDdbG6BWtaPK7MQt1_Muv90yc3wrAr6Xe9mBoNNsQ
+ hash: v1.k794b7964.b844f9a09e6ebbad8d8ae458b33bde2936742262d1b1c1ffbbdcc90e1ab06221.cAy7C44N5Nb60X6CC3IGiVCwjY9vNUq49gZ2ui51Ew0
scenes-app-notebooks--text-formats--dark:
hash: v1.k794b7964.6ba17ee8c1d8e0b4095b903100109314b701baa0a4956ca272f2b26f4d37879b.J-tNiP80EM3tE0ZaOdrZZ3vzZnEK1UdW5afDzziYijQ
scenes-app-notebooks--text-formats--light:
@@ -6535,29 +6535,29 @@ snapshots:
scenes-app-notebooks-components-notebook-select-button--with-slow-network-response--light:
hash: v1.k794b7964.678b0f73befa0690622fd5eb7a920f5c25919af7a9b516a08756e866b37de352.QhzKGfEQA_MQykTL8uuyOryngt75iNv9BydvL5ckPjQ
scenes-app-notebooks-nodes-customer-journey--all-steps-completed--dark:
- hash: v1.k794b7964.b9dafbf2c207f36c51c08af1bdd825839cc43fe3eaf4ae515e2cb1da88669375.MsEW1urtNLTV2huTSXsbkmxJGOF4ZoTXjPMzzKoE500
+ hash: v1.k794b7964.b94ebe6c801275424991cdf5ce4eb8a96b3dd7396c73a52fbb5a7f3d12a15068.hFu00LQH66ItE_Drb7ulV97qHnEQhtkTj6xFPNDXCGQ
scenes-app-notebooks-nodes-customer-journey--all-steps-completed--light:
- hash: v1.k794b7964.df1e365ec572533c74a9b7dda86f2f2547ee47a81973b1cf365c20b93e826d3f.P4rFgrHmbhnyfX-17kDChIgQq2dQLdBJt2MJEqeo5CY
+ hash: v1.k794b7964.4113e899994b3e11be7f11c644246f1188f9fbc79888523d73918e462d2ad69e.eOv4jXkHqWJ40c1R3Y16_8PP9wkxjaDn0LGDUM0TscE
scenes-app-notebooks-nodes-customer-journey--no-steps-completed--dark:
- hash: v1.k794b7964.19b7ddc5733be17c78e1e91692067d8857505805e532c6cb34d0de329aefcf0b._v9oIhfppDsmZw_ejRuLdgQZoFyX45ytKlWIjRUW2PQ
+ hash: v1.k794b7964.8bd21b17105b8b063414ee164d0024348a7102c523b6d5976807f5fb7c55a701.FGb22hh3ogJZAfe9nnR8ZxY0DR8J9TTaIPVuR-RKzLo
scenes-app-notebooks-nodes-customer-journey--no-steps-completed--light:
- hash: v1.k794b7964.e2cf7d5f1c6f6d05fbfc4ebea4c27e25a48d26dba3fb6f65fb2edbc8d40e196b.qtwco_WVfouwj0oGO0V9sku61gRdwZM8k8k3aQ3BbgE
+ hash: v1.k794b7964.c62ca9df283588709e93c98bdf17ecfce82e95ef87f3fab468888ae2876bb764.bdPnzvwGqQkTGsdyjrdkf5VpQDo_O3U1C9qfZWmZ2pU
scenes-app-notebooks-nodes-customer-journey--some-steps-completed--dark:
- hash: v1.k794b7964.beb2071e026c0201549bcf3edfadfbc4a48ebdbfef3e0e9d1d68307a6d3b8652.X73B707qeRj9as3olCv67OVstBsutdQOFQAbRtC_Lc8
+ hash: v1.k794b7964.6a14a5f61907fcb5e498673523439d6f4a4656abb24d4a10aff610651df30507.RonkMxoGopUpdybCoEmlUXGhCe__AXh7g_tWh5t-b1c
scenes-app-notebooks-nodes-customer-journey--some-steps-completed--light:
- hash: v1.k794b7964.489054dc3e10082d70b375d092485479c46bd1b4510653fcab7869b423175ef9.ac39lgSlwCOCxR2KcqJ_XwOQgbtDK_aDq0qQSAStUtA
+ hash: v1.k794b7964.a23e4e2d8e2b57fde1fe00a712aea080e63154b0afccb6978ca5a51bb617ecc2.2TtuMM7o_e-493ewoo1amOjHD2J4tNblJ4hGdC6MSTA
scenes-app-notebooks-nodes-customer-journey--with-optional-steps--dark:
- hash: v1.k794b7964.29817ba8d619ac9a4aeb8adb87e79c7e29785b05ca4ef28f857f5fcc51546155.R6cv899BWVXYej49Y42ofSZRLJm5iHrLwLumvxrSN2s
+ hash: v1.k794b7964.87da3e015b14a2155c496573da2eaa4507d465a22d0ee250e299ce8f26d57a1f.EerzBOCZUX1jlGPBzK9uWEFxWYR06nk7KKP5tllyV9o
scenes-app-notebooks-nodes-customer-journey--with-optional-steps--light:
- hash: v1.k794b7964.bcbc0edb9b6486297014302eb2377d79b9242b3298d61b8b4c60d0183c47c4bf.f2qWVBioZdpdJMnb44JqK9kb8XOeuTeVSXcPG1tApVE
+ hash: v1.k794b7964.121bfeb17a2130a74bda0cb2ba561f6c56e11c13834033a3ef39dd40432271cc.pSCqPjfCB9aUr8yyJ1xkpyRu8z5jlnGD8kHMWg-Ynpg
scenes-app-notebooks-nodes-support-tickets--empty--dark:
- hash: v1.k794b7964.1dbba01ca509f56e0f5903831110a6d48738d875d64a82899f1c8c8a8988cf70.SocGDWVJVEhwWpCapajMXl_qh7p2DKJn6XXPdiU48lQ
+ hash: v1.k794b7964.c10ab277396f4beab2f74bd77e785c75ede9f45b685c4255f9f89741035acf49.xcNVKC2tTI9utsycdzLuJmWfAsvCvh_Zib3ioZFfiTA
scenes-app-notebooks-nodes-support-tickets--empty--light:
- hash: v1.k794b7964.e8b97a3330f2c3716bbc41c92e96784d9c53ee924acc06b3a349a79fbc3381a1.iVnUNqyFuwZY0PU4iKmrHTfhobgB_eoTQFAZm7B99-I
+ hash: v1.k794b7964.8f8b52acc8bb55637bd7f08900e425729d2260849d4f736596afaa809a4db2d7.XS5NtFMSF3rgnNJsHwnpuDCZv4JAImonICFoLfT5zHI
scenes-app-notebooks-nodes-support-tickets--with-tickets--dark:
- hash: v1.k794b7964.f140dd1cfd963fd9631e50bf3bce79a089fc4901837a1c986aa3b8fba5d48943.h_gOREY-7-99SbBk_6qcivjwEaqt_s07TU-y5N15bDE
+ hash: v1.k794b7964.3cf38fb9c9a40942eece565d903573597c3d904666c6384a5bab2cbcf9644a5d.E9uJYL0s1GLzlbYJOal_S-NOkj6ht4j_DzLSWuq4WW4
scenes-app-notebooks-nodes-support-tickets--with-tickets--light:
- hash: v1.k794b7964.ba5256639fbf4ee3a903bc01ef246206dfb3d9b7bc7bf42be54bc5f5734af15f.RFx8KQInm_QZk3nfRuK0YTkkk9Pnabd3GGEpURiuKS8
+ hash: v1.k794b7964.5006f99a89dd836d27796f18c961195c3d1481a2f098ed4366350f9d9ed3ad17.DmBrFHnDUAo9rYBJKBNmfJY5MZnmjixLZo06TMwyYS8
scenes-app-oauth-authorize--all-scopes-optional--dark:
hash: v1.k794b7964.03746d2e3646b97e4af61e54557db2ccb6268512cda02721b819fa30980af155.ZPcclnqMQQh8Qi_v2Z3cnVA1_LaYFx8XXncRQ8NQAdc
scenes-app-oauth-authorize--all-scopes-optional--light:
diff --git a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss
index 3dbd818a1bc3..7738576492c8 100644
--- a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss
+++ b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss
@@ -1666,9 +1666,10 @@ h3.MarkdownNotebook__text-block--heading {
flex: 1 1 0;
min-width: 0;
overflow: hidden;
- font-size: 0.8125rem;
+ font-size: 1rem;
+ font-weight: 500;
line-height: 1.4;
- color: var(--color-text-secondary);
+ color: var(--color-text-primary);
text-overflow: ellipsis;
white-space: nowrap;
}
@@ -1697,6 +1698,34 @@ h3.MarkdownNotebook__text-block--heading {
}
}
+.MarkdownNotebook__component-toolbar-title--button {
+ padding: 0.125rem 0.375rem;
+ font-family: inherit;
+ text-align: left;
+ appearance: none;
+ cursor: pointer;
+ background: transparent;
+ border: 1px solid transparent;
+ border-radius: 0.25rem;
+ transition:
+ background-color 120ms ease,
+ border-color 120ms ease;
+
+ &:hover {
+ background: var(--color-bg-fill-tertiary);
+ }
+
+ &:focus-visible {
+ border-color: var(--color-accent);
+ outline: none;
+ }
+}
+
+.MarkdownNotebook__component-toolbar-title-placeholder {
+ font-weight: 400;
+ color: var(--color-text-tertiary);
+}
+
.MarkdownNotebook__component-actions {
flex: 0 0 auto;
}
diff --git a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.test.ts b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.test.ts
index f4b0ec79bc36..32c3fc74c22d 100644
--- a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.test.ts
+++ b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.test.ts
@@ -9095,6 +9095,9 @@ After component`,
onChange,
})
)
+ fireEvent.doubleClick(
+ container.querySelector('.MarkdownNotebook__component-toolbar-title--button') as HTMLElement
+ )
const titleInput = container.querySelector(
'input.MarkdownNotebook__component-toolbar-title--input'
) as HTMLInputElement
@@ -9116,6 +9119,9 @@ After component`,
onChange,
})
)
+ fireEvent.doubleClick(
+ container.querySelector('.MarkdownNotebook__component-toolbar-title--button') as HTMLElement
+ )
const titleInput = container.querySelector(
'input.MarkdownNotebook__component-toolbar-title--input'
) as HTMLInputElement
@@ -9125,7 +9131,8 @@ After component`,
fireEvent.keyDown(titleInput, { key: 'Escape' })
expect(onChange).not.toHaveBeenCalled()
- expect(titleInput.value).toEqual('')
+ // Escape closes the rename input without persisting; the title stays empty.
+ expect(container.querySelector('input.MarkdownNotebook__component-toolbar-title--input')).toBeNull()
})
it('shows the saved component title read-only in view mode', () => {
@@ -9156,6 +9163,9 @@ After component`,
const { container } = render(
createElement(MarkdownNotebook, { value: '<SummaryCard id="summary-id" />', registry })
)
+ fireEvent.doubleClick(
+ container.querySelector('.MarkdownNotebook__component-toolbar-title--button') as HTMLElement
+ )
const titleInput = container.querySelector(
'input.MarkdownNotebook__component-toolbar-title--input'
) as HTMLInputElement
@@ -9167,9 +9177,16 @@ After component`,
})
it('does not suggest the query body or schema kinds as the title placeholder', () => {
- const getPlaceholder = (): string =>
- (container.querySelector('input.MarkdownNotebook__component-toolbar-title--input') as HTMLInputElement)
- .placeholder
+ const getPlaceholder = (): string => {
+ if (!container.querySelector('input.MarkdownNotebook__component-toolbar-title--input')) {
+ fireEvent.doubleClick(
+ container.querySelector('.MarkdownNotebook__component-toolbar-title--button') as HTMLElement
+ )
+ }
+ return (
+ container.querySelector('input.MarkdownNotebook__component-toolbar-title--input') as HTMLInputElement
+ ).placeholder
+ }
const { container, rerender } = render(
createElement(MarkdownNotebook, {
value: '<DuckSQL code="select * from events" returnVariable="duck_df" />',
@@ -9262,8 +9279,14 @@ After component`,
ViewComponent: () => createElement('div', { 'data-testid': 'summary-output' }, 'Loading'),
},
])
- const getTitleInput = (): HTMLInputElement =>
- container.querySelector('input.MarkdownNotebook__component-toolbar-title--input') as HTMLInputElement
+ const getTitleInput = (): HTMLInputElement => {
+ if (!container.querySelector('input.MarkdownNotebook__component-toolbar-title--input')) {
+ fireEvent.doubleClick(
+ container.querySelector('.MarkdownNotebook__component-toolbar-title--button') as HTMLElement
+ )
+ }
+ return container.querySelector('input.MarkdownNotebook__component-toolbar-title--input') as HTMLInputElement
+ }
const { container, rerender } = render(
createElement(MarkdownNotebook, { value: '<SummaryCard id="summary-id" />', registry })
)
diff --git a/frontend/src/lib/components/MarkdownNotebook/NotebookComponentShell.tsx b/frontend/src/lib/components/MarkdownNotebook/NotebookComponentShell.tsx
index 82c9430fa594..7d8368466c6e 100644
--- a/frontend/src/lib/components/MarkdownNotebook/NotebookComponentShell.tsx
+++ b/frontend/src/lib/components/MarkdownNotebook/NotebookComponentShell.tsx
@@ -5,6 +5,7 @@ import {
PointerEvent as ReactPointerEvent,
ReactNode,
memo,
+ useEffect,
useMemo,
useRef,
useState,
@@ -113,6 +114,19 @@ export function NotebookComponentShell({
[componentPanels, showEditPanel, showViewPanel]
)
const [titleDraft, setTitleDraft] = useState<string | null>(null)
+ const [isEditingTitle, setIsEditingTitle] = useState(false)
+ // A browser fires two `click`s before `dblclick`. Defer the title's collapse so a rename
+ // (double-click) can cancel it, otherwise renaming would collapse then restore the panels
+ // (a flicker) and persist the node twice.
+ const titleCollapseTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
+ useEffect(
+ () => () => {
+ if (titleCollapseTimerRef.current) {
+ clearTimeout(titleCollapseTimerRef.current)
+ }
+ },
+ []
+ )
// Escape blurs the input, which fires commitTitle synchronously before the titleDraft
// state update lands — this ref lets commitTitle see the cancel intent in that same tick
const cancellingTitleRef = useRef(false)
@@ -310,16 +324,56 @@ export function NotebookComponentShell({
) : null}
</div>
{mode === 'edit' ? (
- <input
- className="MarkdownNotebook__component-toolbar-title MarkdownNotebook__component-toolbar-title--input"
- value={titleInputValue}
- placeholder={titlePlaceholder}
- aria-label="Component title"
- spellCheck={false}
- onChange={(event) => setTitleDraft(event.target.value)}
- onBlur={commitTitle}
- onKeyDown={handleTitleKeyDown}
- />
+ isEditingTitle ? (
+ <input
+ className="MarkdownNotebook__component-toolbar-title MarkdownNotebook__component-toolbar-title--input"
+ value={titleInputValue}
+ placeholder={titlePlaceholder}
+ aria-label="Component title"
+ spellCheck={false}
+ autoFocus
+ onChange={(event) => setTitleDraft(event.target.value)}
+ onBlur={() => {
+ commitTitle()
+ setIsEditingTitle(false)
+ }}
+ onKeyDown={handleTitleKeyDown}
+ />
+ ) : (
+ // Clicking the title collapses the whole cell (same as hiding both panels);
+ // double-click renames. No extra control is added to the toolbar.
+ <button
+ type="button"
+ className="MarkdownNotebook__component-toolbar-title MarkdownNotebook__component-toolbar-title--button"
+ title={resolvedTitle ?? titlePlaceholder}
+ aria-expanded={hasOpenComponentPanel}
+ onClick={() => {
+ if (!canToggleComponentPanels) {
+ return
+ }
+ if (titleCollapseTimerRef.current) {
+ clearTimeout(titleCollapseTimerRef.current)
+ }
+ titleCollapseTimerRef.current = setTimeout(() => {
+ titleCollapseTimerRef.current = null
+ toggleAllComponentPanels()
+ }, 250)
+ }}
+ onDoubleClick={() => {
+ if (titleCollapseTimerRef.current) {
+ clearTimeout(titleCollapseTimerRef.current)
+ titleCollapseTimerRef.current = null
+ }
+ setIsEditingTitle(true)
+ }}
+ >
+ {resolvedTitle ?? (
+ <span className="MarkdownNotebook__component-toolbar-title-placeholder">
+ {titlePlaceholder}
+ </span>
+ )}
+ </button>
+ )
) : resolvedTitle ? (
<div className="MarkdownNotebook__component-toolbar-title" title={resolvedTitle}>
{resolvedTitle}