From 438e03861b4eacede15b842f1d0995d84b8f4a98 Mon Sep 17 00:00:00 2001 From: TianYun Date: Mon, 1 Jun 2026 17:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=AC=BE=E6=B0=B8=E8=BF=9C?= =?UTF-8?q?=E5=9C=A8=E4=B8=8B=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/GenerationComposer.test.tsx | 4 ++-- src/components/composer/GenerationComposer.tsx | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/components/__tests__/GenerationComposer.test.tsx b/src/components/__tests__/GenerationComposer.test.tsx index 952ea174..089fffc2 100644 --- a/src/components/__tests__/GenerationComposer.test.tsx +++ b/src/components/__tests__/GenerationComposer.test.tsx @@ -381,7 +381,7 @@ describe("GenerationComposer", () => { expect(screen.getByPlaceholderText(/Describe what you want to generate/)).toHaveClass("h-36"); }); - it("places the selected node editor above the node when below would leave the viewport", () => { + it("keeps the selected node editor below the node when below would leave the viewport", () => { const originalInnerHeight = window.innerHeight; const originalInnerWidth = window.innerWidth; Object.defineProperty(window, "innerHeight", { configurable: true, value: 500 }); @@ -400,7 +400,7 @@ describe("GenerationComposer", () => { expect(screen.getByTestId("node-inline-composer")).toHaveStyle({ left: "16px", - top: "104px", + top: "536px", }); Object.defineProperty(window, "innerHeight", { configurable: true, value: originalInnerHeight }); Object.defineProperty(window, "innerWidth", { configurable: true, value: originalInnerWidth }); diff --git a/src/components/composer/GenerationComposer.tsx b/src/components/composer/GenerationComposer.tsx index 283cfd33..14e5a247 100644 --- a/src/components/composer/GenerationComposer.tsx +++ b/src/components/composer/GenerationComposer.tsx @@ -124,8 +124,6 @@ const MAX_REFERENCE_IMAGE_BYTES = 10 * 1024 * 1024; const COMPOSER_VIEWPORT_MARGIN = 16; const COMPOSER_EXPANDED_WIDTH = 640; const COMPOSER_COLLAPSED_WIDTH = 560; -const COMPOSER_EXPANDED_HEIGHT_ESTIMATE = 300; -const COMPOSER_COLLAPSED_HEIGHT_ESTIMATE = 80; const DEFAULT_IMAGE_COUNT_OPTIONS: ImageGenerationCount[] = [1, 2, 4]; interface SchemaSelectOption { @@ -1408,16 +1406,10 @@ export function GenerationComposer() { ); const safeZoom = zoom > 0 ? zoom : 1; const viewportWidth = typeof window === "undefined" ? Number.POSITIVE_INFINITY : window.innerWidth; - const viewportHeight = typeof window === "undefined" ? Number.POSITIVE_INFINITY : window.innerHeight; const visibleLeft = -viewportX / safeZoom; const visibleRight = (viewportWidth - viewportX) / safeZoom; - const visibleTop = -viewportY / safeZoom; - const visibleBottom = (viewportHeight - viewportY) / safeZoom; const composerWidth = isComposerCollapsed ? COMPOSER_COLLAPSED_WIDTH : COMPOSER_EXPANDED_WIDTH; const composerFlowWidth = composerWidth / safeZoom; - const composerHeightEstimate = isComposerCollapsed - ? COMPOSER_COLLAPSED_HEIGHT_ESTIMATE - : COMPOSER_EXPANDED_HEIGHT_ESTIMATE; const viewportMargin = COMPOSER_VIEWPORT_MARGIN / safeZoom; const inlineComposerPosition = context.node && selectedNodeDimensions ? (() => { @@ -1428,13 +1420,10 @@ export function GenerationComposer() { ? Math.min(Math.max(centeredLeft, minLeft), maxLeft) : minLeft; const belowTop = context.node.position.y + selectedNodeDimensions.height + viewportMargin; - const aboveTop = context.node.position.y - composerHeightEstimate / safeZoom - viewportMargin; - const belowFits = belowTop + composerHeightEstimate / safeZoom <= visibleBottom - viewportMargin; - const aboveFits = aboveTop >= visibleTop + viewportMargin; return { left, - top: belowFits || !aboveFits ? belowTop : aboveTop, + top: belowTop, }; })() : null;