File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,19 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
369369 var window = Window . GetWindow ( dialogHost ) ;
370370 dialogHost . _restoreFocusDialogClose = window != null ? FocusManager . GetFocusedElement ( window ) : null ;
371371
372+ /* The root cause of the issue is that dialogHost._restoreFocusDialogClose at this point is a TabItem.
373+ * So when trying to restore focus when the dialog closes, it will call .Focus() on the TabItem which
374+ * effectively does a tab switch if that TabItem is not currently the selected TabItem.
375+ *
376+ * This IS NOT the right fix, but showcases the issue. How can we go about creating a generic fix for this?
377+ * I don't believe TabControl is the only control which is facing this issue. Any control with state similar
378+ * to the TabControl would arguably suffer from the same issue.
379+ */
380+ if ( dialogHost . _restoreFocusDialogClose is TabItem { Parent : TabControl tabControl } )
381+ {
382+ dialogHost . _restoreFocusDialogClose = tabControl ;
383+ }
384+
372385 //multiple ways of calling back that the dialog has opened:
373386 // * routed event
374387 // * the attached property (which should be applied to the button which opened the dialog
You can’t perform that action at this time.
0 commit comments