From 685f251f1b67e6cd23efee049fdef75910d455c0 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 27 Oct 2026 10:54:54 +0800 Subject: [PATCH] Align native editor buttons and sidebar graph switch --- apple/Sources/Logseq/LGNavigationExtension.swift | 4 ++-- apple/Tests/UI/sidebar-long-graph-name.swift | 6 ++++-- shared/src/logseq/view_outliner.ml | 6 ++++-- shared/src/logseq/view_sidebar.ml | 2 +- shared/test/logseq/editor_command_test.ml | 4 ++++ 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apple/Sources/Logseq/LGNavigationExtension.swift b/apple/Sources/Logseq/LGNavigationExtension.swift index e0ec79ff..ca348624 100644 --- a/apple/Sources/Logseq/LGNavigationExtension.swift +++ b/apple/Sources/Logseq/LGNavigationExtension.swift @@ -265,7 +265,7 @@ private struct LGSidebarNavigation: View { child(at: 1) .lineLimit(1) .truncationMode(.middle) - .frame(maxWidth: LGNavigationSurfacePolicy.sidebarGraphWidth(geometry.size.width)) + .frame(width: LGNavigationSurfacePolicy.sidebarGraphWidth(geometry.size.width), alignment: .leading) } .sharedBackgroundVisibility(.hidden) ToolbarItem(placement: .topBarTrailing) { child(at: 2) } @@ -273,7 +273,7 @@ private struct LGSidebarNavigation: View { } else { ToolbarItem(placement: .topBarLeading) { child(at: 1).lineLimit(1).truncationMode(.middle) - .frame(maxWidth: LGNavigationSurfacePolicy.sidebarGraphWidth(geometry.size.width)) + .frame(width: LGNavigationSurfacePolicy.sidebarGraphWidth(geometry.size.width), alignment: .leading) } ToolbarItem(placement: .topBarTrailing) { child(at: 2) } } diff --git a/apple/Tests/UI/sidebar-long-graph-name.swift b/apple/Tests/UI/sidebar-long-graph-name.swift index 77d07abe..6f356e14 100644 --- a/apple/Tests/UI/sidebar-long-graph-name.swift +++ b/apple/Tests/UI/sidebar-long-graph-name.swift @@ -37,8 +37,9 @@ import UIKit } try await Task.sleep(for: .milliseconds(600)) try backend.performPress(node: node("button.sidebar")) - for name in ["Short", "Abhilesh_Knowledge_Graph", String(repeating: "Long graph name ", count: 8), "Short again"] { + for name in ["My notes", "Short", "Abhilesh_Knowledge_Graph", String(repeating: "Long graph name ", count: 8), "Short again"] { try runtime.applyCoreResponse(snapshot(name)) + try backend.performToggle(node: node("application.shell"), checked: true) try await Task.sleep(for: .milliseconds(800)) let settingsID = try node("button.sidebar.settings") let graphID = try node("button.graph-switch") @@ -47,9 +48,10 @@ import UIKit } guard let settings = frames[settingsID], let graph = frames[graphID], settings.width >= 40, settings.height >= 40, + graph.minX >= 12, graph.width >= 80, window.bounds.contains(settings), window.bounds.contains(graph), settings.minX >= graph.maxX - 1 else { - throw failure("Global settings must remain visible and unobscured for graph \(name): settings=\(String(describing: frames[settingsID])) graph=\(String(describing: frames[graphID]))") + throw failure("The graph switch must fit its label without clipping and preserve Settings for graph \(name): settings=\(String(describing: frames[settingsID])) graph=\(String(describing: frames[graphID]))") } } try backend.performPress(node: node("button.sidebar.settings")) diff --git a/shared/src/logseq/view_outliner.ml b/shared/src/logseq/view_outliner.ml index 5c5936dd..9f02a5a4 100644 --- a/shared/src/logseq/view_outliner.ml +++ b/shared/src/logseq/view_outliner.ml @@ -1059,8 +1059,10 @@ let outliner_editor_toolbar (context : Lui_ui.ui_context) model_source send Option.fold ~none:false ~some:(fun editing -> List.exists (fun (row : Model.outline_row) -> row.row_uuid = editing.Model.editing_uuid && row.row_display_type = Some "code") current.outliner_rows) current.outliner_editing) model_source) - (button ~icon:(`app "add") ~variant:`ghost ~size:`icon - ~width:(if Lui_ui.host context = KotlinHost then 48 else 38) ~height:42 + (button ~icon:(`app "add") ~variant:`ghost + ?size:(if Lui_ui.host context = KotlinHost then Some `icon else None) + ~width:(if Lui_ui.host context = KotlinHost then 48 else 38) + ~height:(if Lui_ui.host context = KotlinHost then 48 else 42) ~label:(View_base.tr (Signal.sample model_source) "Create new block") ~accessibility_identifier:"button.outliner.editor.newBlock" ~on_press:(fun _ -> ignore (send (Model.PerformOutlinerToolbarAction "newBlock"))) []) in diff --git a/shared/src/logseq/view_sidebar.ml b/shared/src/logseq/view_sidebar.ml index 5ff05802..094b815a 100644 --- a/shared/src/logseq/view_sidebar.ml +++ b/shared/src/logseq/view_sidebar.ml @@ -91,7 +91,7 @@ let sidebar_graph_switch (context : Lui_ui.ui_context) model_source send : t = [ sidebar_graph_switch_content model_source ]) else View_base.with_label "Switch graph" - (button ~variant:`ghost ~min_height:44 + (button ~variant:`ghost ~min_height:44 ~grow:1.0 ~text_signal:(Signal.map View_base.graph_label model_source) ~text_alignment:`start ~style_class:"semibold" ~foreground:"foreground" ~icon:(`app "chevron-down") ~icon_placement:`trailing diff --git a/shared/test/logseq/editor_command_test.ml b/shared/test/logseq/editor_command_test.ml index 2f20c2a5..934171a3 100644 --- a/shared/test/logseq/editor_command_test.ml +++ b/shared/test/logseq/editor_command_test.ml @@ -460,6 +460,10 @@ let code_toolbar_creates_a_block_without_a_hardware_keyboard () = let host = Lui_app.runtime app in let button = App_test.descendant_with_identifier host (Lui_app.root_node app) "button.outliner.editor.newBlock" in check ~msg:"the software keyboard exposes New block for Code and Calculator" (button <> -1); + let neighbor = App_test.descendant_with_identifier host (Lui_app.root_node app) "button.outliner.editor.moveDown" in + List.iter (fun key -> check_eq ~msg:"New block matches neighboring toolbar controls" + (App_test.property host button key) (App_test.property host neighbor key)) + [Lui_protocol.WidthValue; Lui_protocol.HeightValue; Lui_protocol.SizeValue; Lui_protocol.VariantValue]; App_test.dispatch app (Lui_protocol.Press button); App_test.flush app; check ~msg:"the native toolbar forwards the shared structural action" (List.exists (function Model.OutlinerToolbarEffect (_, "newBlock") -> true | _ -> false)