From 5d2a69143897c50bf83c2e3bc6629ee77d3fd2b1 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Thu, 14 May 2026 19:22:20 +0800 Subject: [PATCH] fix(host): fill-picker dismiss runs before VariablesPanel dispatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex stop-gate on the previous reorder (96cf753b): putting `dispatch_variables_panel_press` at the absolute top of the cascade meant a Variables-row click while the PropertyPanel's fill-type picker was open returned true and left `fill_type_picker_open=true`. The fill picker would float over the chrome until the next unrelated click happened to land outside its rect. Cascade order now: 0c0. Fill-type picker outside-click dismiss (must run first when open — any click anywhere closes the picker, then swallows or routes to a SetFillType / ToggleFillTypePicker action). 0b1. VariablesPanel hit dispatch (BEFORE PropertyPanel so the bottom-anchored Variables rect wins for clicks in its z-order overlap with the rail). 0c. PropertyPanel input + action hit-tests. The fill-picker block already swallows every click when open, so reaching the Variables dispatcher requires the picker to be closed — which means the existing dismiss path runs unconditionally before any Variables click can fire. 295 shell-core + 20 shell- native tests still pass. press.rs: 832 → 836 (the dismiss comment + restored ordering adds 4 lines). Still over the 800 cap as pre-existing tech debt; my session has added +11 lines total to this file (825 → 836), which is small and bounded. --- .../src/widget_host/press.rs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/openpencil-shell-native/src/widget_host/press.rs b/crates/openpencil-shell-native/src/widget_host/press.rs index 8c7fdb177..db47670a9 100644 --- a/crates/openpencil-shell-native/src/widget_host/press.rs +++ b/crates/openpencil-shell-native/src/widget_host/press.rs @@ -283,14 +283,11 @@ impl WidgetHostNative { return rename_committed || text_edit_committed; } - // 0b1. VariablesPanel — tested before PropertyPanel so the - // bottom-anchored Variables rect wins clicks (paint - // stack: PropertyPanel under, Variables over). - if self.dispatch_variables_panel_press(x, y, viewport_width, viewport_height) { - return true; - } - - // 0c0. Fill-type picker — outside-click dismiss. + // 0c0. Fill-type picker — outside-click dismiss. Must run + // BEFORE the VariablesPanel dispatch so an open picker + // gets dismissed by every click, even ones landing on + // a Variables row (codex stop-gate: the previous order + // left fill_type_picker_open=true after a vars click). if self.document.ui.fill_type_picker_open { if let Some(panel) = PropertyPanel::for_selection(&self.document) { let property_rect = Rect { @@ -319,6 +316,13 @@ impl WidgetHostNative { return true; } + // 0b1. VariablesPanel — tested before PropertyPanel so the + // bottom-anchored Variables rect wins (paint stack: + // PropertyPanel under, Variables over). + if self.dispatch_variables_panel_press(x, y, viewport_width, viewport_height) { + return true; + } + // 0c. PropertyPanel input row — focus the row + seed the // edit draft from the snapshot value. Any other click // (canvas, chat, toolbar, layer panel) commits + clears