From 3362e46effbfe28827974272f242846b18cc22a8 Mon Sep 17 00:00:00 2001 From: Fabian Stettler Date: Sun, 3 Aug 2025 21:07:03 +0200 Subject: [PATCH] When typing in the embedded search TextBox, pressing Spacebar was bubbling up to the TableView, causing unintended row selection or scrolling. This fix: - marks the Space key event as handled when focus is in the search box - manually inserts a space character into the TextBox at the caret - prevents TableView from reacting to Space input during search Fixes #169 --- src/TableViewColumnHeader.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/TableViewColumnHeader.cs b/src/TableViewColumnHeader.cs index ec5d15e..db23f9e 100644 --- a/src/TableViewColumnHeader.cs +++ b/src/TableViewColumnHeader.cs @@ -261,6 +261,22 @@ private void OnSearchBoxKeyDown(object sender, KeyRoutedEventArgs e) e.Handled = true; } + else if (e.Key == VirtualKey.Space) + { + // Prevent the Space key event from bubbling up to the TableView + // but still allow normal text input + + e.Handled = true; + + // Manually add the space character to the TextBox + if (_searchBox != null) + { + var selectionStart = _searchBox.SelectionStart; + var currentText = _searchBox.Text ?? string.Empty; + _searchBox.Text = currentText.Insert(selectionStart, " "); + _searchBox.SelectionStart = selectionStart + 1; + } + } } ///