From 3577f95cb7dbd5182102531459141966bb18b240 Mon Sep 17 00:00:00 2001 From: Martin Garstenauer Date: Fri, 12 Jun 2026 12:50:40 +0200 Subject: [PATCH] Fix: CompletionWindow closes when clicking/dragging the scrollbar thumb --- src/AvaloniaEdit/CodeCompletion/CompletionList.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs index 7fc85bb8..0638823b 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs @@ -249,6 +249,10 @@ private void OnPointerPressed(object sender, PointerPressedEventArgs e) if (!e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed) return; + // Ignore event if pointer is outside the selected item (e.g. when the scrollbar is clicked). + if (!IsPointerOverSelectedItem(e)) + return; + RequestInsertion(e); } @@ -258,13 +262,19 @@ private void OnPointerReleased(object sender, PointerReleasedEventArgs e) return; // Ignore event if pointer is released outside the selected item. - var listBoxItem = _listBox.ContainerFromIndex(_listBox.SelectedIndex); - if (listBoxItem == null || !this.GetVisualsAt(e.GetPosition(this)).Any(v => v == listBoxItem || listBoxItem.IsVisualAncestorOf(v))) + if (!IsPointerOverSelectedItem(e)) return; RequestInsertion(e); } + private bool IsPointerOverSelectedItem(PointerEventArgs e) + { + var listBoxItem = _listBox.ContainerFromIndex(_listBox.SelectedIndex); + return listBoxItem != null && this.GetVisualsAt(e.GetPosition(this)) + .Any(v => v == listBoxItem || listBoxItem.IsVisualAncestorOf(v)); + } + private void OnDoubleTapped(object sender, TappedEventArgs e) { RequestInsertion(e);