From f52cb8779e166e20568199cbb6482ccdd8e837b0 Mon Sep 17 00:00:00 2001 From: Zzy Date: Sat, 22 Aug 2026 00:15:06 +0800 Subject: [PATCH] fix: reserve keyboard inset in layout push --- src/client/Sidebar.tsx | 10 +++++++--- tests/sidebar-layout-push.spec.ts | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/client/Sidebar.tsx b/src/client/Sidebar.tsx index cd58a9c..a9e39fe 100644 --- a/src/client/Sidebar.tsx +++ b/src/client/Sidebar.tsx @@ -694,7 +694,8 @@ export function Sidebar(props: { ctx: Context; store: SidebarStore }) { // `width + detailsWidth` — derived from the measured column, keeping the // drag write-only (no React re-render mid-drag). bottomRef.current?.style.setProperty('right', `${(window.innerWidth - centerRect.right) + (width - (state?.width ?? 0))}px`) - writeGeometry(width, height) + const bottomPush = !narrow && state?.bottomOpen === true ? height + keyboardInset : 0 + writeGeometry(width, bottomPush) } // Drags write at most once per frame: pointer events fire several times @@ -855,8 +856,11 @@ export function Sidebar(props: { ctx: Context; store: SidebarStore }) { viewportWidth: viewport.width, viewportHeight: layoutViewportHeight, }) - writeGeometry(width, height) - }, [narrow, snapshot.state?.panelOpen, snapshot.state?.width, snapshot.state?.bottomOpen, snapshot.state?.bottomHeight, viewport.width, layoutViewportHeight]) + const bottomPush = !narrow && snapshot.state?.bottomOpen === true + ? height + keyboardInset + : 0 + writeGeometry(width, bottomPush) + }, [narrow, snapshot.state?.panelOpen, snapshot.state?.width, snapshot.state?.bottomOpen, snapshot.state?.bottomHeight, viewport.width, layoutViewportHeight, keyboardInset]) // Unmount must release the push (issue #31): when the boundary swaps the // whole sidebar after a render crash (or the plugin fiber is disposed / // HMR), the CSS variables would otherwise stay on and layout.css diff --git a/tests/sidebar-layout-push.spec.ts b/tests/sidebar-layout-push.spec.ts index b94de12..1f0ea1b 100644 --- a/tests/sidebar-layout-push.spec.ts +++ b/tests/sidebar-layout-push.spec.ts @@ -13,7 +13,13 @@ describe('Sidebar layout-push integration', () => { expect(source).toContain('setVisualViewportHeight(Math.max(0, Math.round(vv.height)))') expect(source).toContain('visualViewportHeight ?? viewport.height') expect(source.match(/viewportHeight: layoutViewportHeight/g)).toHaveLength(4) - expect(source).toContain('viewport.width, layoutViewportHeight]') + expect(source).toContain('viewport.width, layoutViewportHeight, keyboardInset]') + }) + + it('adds the keyboard inset to the conversation push, not the panel height', () => { + expect(source.match(/height \+ keyboardInset/g)).toHaveLength(2) + expect(source).toContain('height: bottomPanelHeight') + expect(source).not.toContain('height: bottomPanelHeight + keyboardInset') }) it('reapplies the visible-height cap to every vertical drag result', () => {