From 2c7670f06c7512a813a6711289f5dd550ac8bf38 Mon Sep 17 00:00:00 2001 From: Codex CLI Date: Mon, 1 Sep 2025 02:59:03 -0500 Subject: [PATCH] fix: prevent double insertion from functions list\n\n- Remove flyout-level tap wiring that duplicated item taps\n- Keep a single per-item tap handler for function rows --- src/AdvancedCalculator/Views/MainView.axaml | 6 ++-- .../Views/MainView.axaml.cs | 28 ++----------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/AdvancedCalculator/Views/MainView.axaml b/src/AdvancedCalculator/Views/MainView.axaml index e9b804d..5274b5a 100644 --- a/src/AdvancedCalculator/Views/MainView.axaml +++ b/src/AdvancedCalculator/Views/MainView.axaml @@ -136,9 +136,7 @@ + Placement="BottomEdgeAlignedLeft"> @@ -162,7 +160,7 @@ + Tapped="OnFunctionsItemTapped"> diff --git a/src/AdvancedCalculator/Views/MainView.axaml.cs b/src/AdvancedCalculator/Views/MainView.axaml.cs index 5a3bbd9..bb86741 100644 --- a/src/AdvancedCalculator/Views/MainView.axaml.cs +++ b/src/AdvancedCalculator/Views/MainView.axaml.cs @@ -21,7 +21,7 @@ public partial class MainView : UserControl private MainViewModel? _vm; private ListBox? _historyList; - private Border? _functionsPanelRoot; + // Functions flyout is handled via per-item Tapped in XAML private void OnAttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { @@ -53,12 +53,6 @@ public partial class MainView : UserControl _historyList.RemoveHandler(InputElement.TappedEvent, OnHistoryTapped); _historyList = null; } - // Detach functions panel tap handler if still attached - if (_functionsPanelRoot is not null) - { - _functionsPanelRoot.RemoveHandler(InputElement.TappedEvent, OnFunctionsItemTapped); - _functionsPanelRoot = null; - } _vm = null; } @@ -104,23 +98,5 @@ public partial class MainView : UserControl } } - - private void OnFunctionsFlyoutOpened(object? sender, EventArgs e) -{ - if (sender is Flyout flyout && sender is ContentPresenter presenter) - { - _functionsPanelRoot = presenter.FindControl("FunctionsPanelRoot"); - _functionsPanelRoot?.AddHandler(InputElement.TappedEvent, OnFunctionsItemTapped, - RoutingStrategies.Tunnel | RoutingStrategies.Bubble); - } -} - - private void OnFunctionsFlyoutClosed(object? sender, EventArgs e) - { - if (_functionsPanelRoot is not null) - { - _functionsPanelRoot.RemoveHandler(InputElement.TappedEvent, OnFunctionsItemTapped); - _functionsPanelRoot = null; - } - } + // Removed Opened/Closed dynamic wiring; handled directly in XAML. }