From d4e035d03f8f17fd70d01071e39a5ea5a7d5cdaf Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Fri, 29 May 2026 21:23:46 +0800 Subject: [PATCH] fix(panels): keep file-menu dropdown anchor in sync with the divider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new sidebar↔file-menu divider shifted the folder button right, but `TopBar::file_menu_rect` (the dropdown anchor) still used the pre-divider x, so the file menu opened left of its button (Codex stop-time review). Route the anchor through the divider span and have hit_test reuse `file_menu_rect` so paint / hit-test / anchor can't drift again. --- crates/op-editor-ui/src/widgets/top_bar.rs | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/op-editor-ui/src/widgets/top_bar.rs b/crates/op-editor-ui/src/widgets/top_bar.rs index 44feefedf..93c0190f1 100644 --- a/crates/op-editor-ui/src/widgets/top_bar.rs +++ b/crates/op-editor-ui/src/widgets/top_bar.rs @@ -235,8 +235,16 @@ impl TopBar { /// chevron compound). Host anchors the dropdown directly under /// this rect when `Document.ui.file_menu_open == true`. pub fn file_menu_rect(top_bar_rect: Rect, fullscreen: bool) -> Rect { - let file_menu_x = - top_bar_rect.origin.x + PAD + Self::left_inset_for(fullscreen) + ICON_BUTTON + 4.0; + // Mirror the paint layout: panel button │ divider │ file-menu. + // The divider span (gap + width + gap) pushes the file-menu + // right of the sidebar toggle — keep this anchor in sync so + // the dropdown opens under the folder button, not left of it. + let divider_span = DIVIDER_GAP + DIVIDER_W + DIVIDER_GAP; + let file_menu_x = top_bar_rect.origin.x + + PAD + + Self::left_inset_for(fullscreen) + + ICON_BUTTON + + divider_span; Rect { origin: Point2D::new(file_menu_x, top_bar_rect.origin.y + 8.0), size: Point2D::new(FILE_MENU_BUTTON_WIDTH, ICON_BUTTON), @@ -309,14 +317,12 @@ impl TopBar { if rect_contains(panel_left_rect, point) { return Some(TopBarHit::ToggleSidebar); } - // Mirror the paint layout: panel │ file-menu │ Figma, each - // group split by a divider (DIVIDER_GAP + DIVIDER_W + DIVIDER_GAP). + // Reuse the canonical anchor so the hit area, paint, and + // dropdown anchor can never drift (Codex caught a divider-span + // drift here once). + let file_menu_rect = Self::file_menu_rect(rect, self.fullscreen); + let file_menu_x = file_menu_rect.origin.x; let divider_span = DIVIDER_GAP + DIVIDER_W + DIVIDER_GAP; - let file_menu_x = rect.origin.x + PAD + self.left_inset() + ICON_BUTTON + divider_span; - let file_menu_rect = Rect { - origin: Point2D::new(file_menu_x, icon_y), - size: Point2D::new(FILE_MENU_BUTTON_WIDTH, ICON_BUTTON), - }; if rect_contains(file_menu_rect, point) { return Some(TopBarHit::ToggleFileMenu); }