From 12815670865183943919e848568b2fbbd3bd94a4 Mon Sep 17 00:00:00 2001 From: Kevin Bost Date: Thu, 9 Jul 2026 22:21:44 -0700 Subject: [PATCH] Remove explicit Win32 SetFocus call when opening DialogHost The manual call to SetFocus via HwndSource was redundant and could cause unexpected focus behavior. The subsequent logic already handles focus by finding the first focusable element within the dialog's content. --- src/MaterialDesignThemes.Wpf/DialogHost.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/MaterialDesignThemes.Wpf/DialogHost.cs b/src/MaterialDesignThemes.Wpf/DialogHost.cs index 4e919f2552..99f88d49db 100644 --- a/src/MaterialDesignThemes.Wpf/DialogHost.cs +++ b/src/MaterialDesignThemes.Wpf/DialogHost.cs @@ -834,11 +834,6 @@ internal void InternalClose(object? parameter) var child = _popup?.Child ?? _popupContentControl; if (child is null) return null; - if (PresentationSource.FromVisual(child) is HwndSource hwndSource) - { - SetFocus(hwndSource.Handle); - } - CommandManager.InvalidateRequerySuggested(); var focusable = child.VisualDepthFirstTraversal().OfType().FirstOrDefault(ui => ui.Focusable); if (focusable is null) return null;