Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): table cell-handle layer no longer shifts documen… (#1823)

sarah58cb3331a45a
diff --git a/.changeset/table-cell-handle-layer-layout-shift.md b/.changeset/table-cell-handle-layer-layout-shift.md
new file mode 100644
index 000000000..96d216c86
--- /dev/null
+++ b/.changeset/table-cell-handle-layer-layout-shift.md
@@ -0,0 +1,7 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Fixed: placing the cursor in a table cell no longer pushes the whole document down. The invisible positioning layer for the table's column/row handle pills (`ok-table-cell-handle-layer`) claimed its own row in the editor's layout grid, and on documents shorter than the window that empty row was stretched to an equal share of the leftover height — a blank band appeared above the document whenever a table was focused. The layer is now pinned into the content's own grid row at zero height, so the handle pills render in exactly the same place with no layout shift.
+
+For maintainers — mechanism: `.tiptap-editor` is a CSS grid with implicit auto rows, and the default `align-content: stretch` distributes leftover block-size equally across in-flow auto tracks; any zero-height direct child still generates a stretchable track. The layer now carries `grid-row: 1; align-self: start`, and `.tiptap-editor-portal-content` declares `grid-row: 1` explicitly so auto-placement doesn't bump the editor body to row 2.
diff --git a/packages/app/src/globals.css b/packages/app/src/globals.css
index 147178e40..6cec6a855 100644
--- a/packages/app/src/globals.css
+++ b/packages/app/src/globals.css
@@ -842,6 +842,11 @@
*/
.tiptap-editor .tiptap-editor-portal-content {
grid-column: content;
+ /* Explicit row: `.ok-table-cell-handle-layer` is pinned to row 1 to share
+ this row (see that rule for why); without an explicit row here,
+ auto-placement would skip the occupied content-column cell and bump the
+ editor body to row 2 whenever the cursor is in a table. */
+ grid-row: 1;
position: relative;
}
@@ -1724,8 +1729,14 @@
scroll container (handles track scroll), and crucially NOT
`view.dom.parentElement`, which TipTap vacuums on `<Activity>` recycle. A
portal into that node desyncs React and throws `removeChild` on navigation
- (see TableCellHandles.tsx). The host has no children of its own height, so it
- adds a zero-height grid row — no layout shift.
+ (see TableCellHandles.tsx). The host is pinned into the content's grid row
+ (`grid-row: 1` here + on `.tiptap-editor-portal-content`) instead of
+ generating its own: `.tiptap-editor` is taller than short documents, and the
+ default `align-content: stretch` hands every in-flow auto row an equal share
+ of the leftover height — an own row for this host would balloon into a blank
+ band ABOVE the document the moment the cursor enters a table. `align-self:
+ start` keeps the host zero-height inside the shared row, so the absolute
+ handles position exactly as they would from an own top row.
Visibility is gated here, not in JS: the layer is rendered whenever the
cursor is in a cell (TableCellHandles owns that), but the pills only paint
@@ -1738,6 +1749,8 @@
pills out of tab order. */
.ok-table-cell-handle-layer {
position: relative;
+ grid-row: 1;
+ align-self: start;
visibility: hidden;
/* Delay the falling edge (visible -> hidden) so Radix's focus-restoration on
Escape / dismiss lands on the (still-focusable) pill BEFORE the layer goes
diff --git a/packages/app/tests/stress/ux-interactions.e2e.ts b/packages/app/tests/stress/ux-interactions.e2e.ts
index a7bca4e0b..8fa698892 100644
--- a/packages/app/tests/stress/ux-interactions.e2e.ts
+++ b/packages/app/tests/stress/ux-interactions.e2e.ts
@@ -77,6 +77,23 @@ test('hidden-editor wrapper does not intercept pointer events (both modes)', asy
await expect(hiddenInSource).toHaveCSS('position', 'absolute');
});
+test('table cell-handle layer does not shift document content', async ({ page, api }) => {
+ const docName = await openFreshDoc(api, page, 'table-handle-layer');
+ await api.replaceDoc(docName, '# Table layer\n\n| A | B |\n| - | - |\n| 1 | 2 |\n\nshort body\n');
+ const heading = page.locator('.ProseMirror h1');
+ await expect(heading).toHaveText('Table layer');
+ const before = await heading.boundingBox();
+ if (!before) throw new Error('heading has no bounding box');
+
+ await page.locator('.ProseMirror table td').first().click();
+ const layer = page.locator('.ok-table-cell-handle-layer');
+ await expect(layer).toBeAttached();
+ await expect(page.locator('[data-testid="table-cell-handle"]:visible')).toHaveCount(2);
+ const after = await heading.boundingBox();
+ if (!after) throw new Error('heading has no bounding box after focus');
+ expect(after.y).toBe(before.y);
+});
+
test('WYSIWYG→Source: typing in ProseMirror appears in CodeMirror', async ({ page, api }) => {
await openFreshDoc(api, page, 'wysiwyg-to-source');
await page.locator('.ProseMirror').click();