Skip to content

Commit 173a34c

Browse files
authored
Proposed fix for 2277 (#2315)
Fixes #2277 There is a contention between allowing the cursor to interact with the editable text box vs controlling the popup's state. This is an attempt at a compromise such that the cursor over the direct text interacts with the text box, but clicking elsewhere will interact with the popup.
1 parent 1f2aa7e commit 173a34c

File tree

2 files changed

+133
-128
lines changed

2 files changed

+133
-128
lines changed

MaterialDesignThemes.Wpf/TextFieldAssist.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,21 +429,24 @@ private static void SetClearHandler(Control box)
429429
private static void ApplyTextBoxViewMargin(Control textBox, Thickness margin)
430430
{
431431
if (margin.Equals(new Thickness(double.NegativeInfinity))
432-
|| textBox.Template == null)
432+
|| textBox.Template is null)
433+
{
433434
return;
435+
}
434436

435437
if (textBox is ComboBox
436438
&& textBox.Template.FindName("PART_EditableTextBox", textBox) is TextBox editableTextBox)
437439
{
438440
textBox = editableTextBox;
439-
if (textBox.Template == null)
440-
return;
441+
if (textBox.Template is null) return;
441442
textBox.ApplyTemplate();
442443
}
443444

444445
if (textBox.Template.FindName("PART_ContentHost", textBox) is ScrollViewer scrollViewer
445446
&& scrollViewer.Content is FrameworkElement frameworkElement)
447+
{
446448
frameworkElement.Margin = margin;
449+
}
447450
}
448451

449452
/// <summary>
@@ -455,7 +458,7 @@ private static void TextBoxViewMarginPropertyChangedCallback(
455458
DependencyObject dependencyObject,
456459
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
457460
{
458-
if (!(dependencyObject is Control box))
461+
if (dependencyObject is not Control box)
459462
{
460463
return;
461464
}

0 commit comments

Comments
 (0)