MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

Refocus after Dialog close triggers Tab change

オープン
#1,121 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement evaluation required
主要言語
C#
スター
16.3k
フォーク
3.5k
平均マージ
1日 22時間
マージ済み PR(30日)
8

説明

The DialogHost tries to "re-focus" the item previously selected. This is the code for it:
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/5533b50a6cff78cb75fbb52e16f7c9e06c62446c/MaterialDesignThemes.Wpf/DialogHost.cs#L268

This is very problematic, when the previous control was a `TabItem`, because Focus()ing a `TabItem` actually activates the respective tab.

Here is a very simple reproduction:
* Have a TabControl within a DialogHost
* Focus a given TabItem (i.e. by clicking on an already active Tab)
* In the SelectionChanging Event of the TabControl Show the Dialog (i.e. "Loading data ...")
* Click another Tab

The following happens:
* DialogHost remembers, that the first tab is currently focused
* The click on the second Tab activates this Tab
* Dialog is shown and closed again, after data is loaded
* Dialog calls Focus() on first tab
=> First tab will be selected again

I just created the issue as I'm not sure, what the best solution for this. My current feeling tells me to just check for `if(!(dialogHost._restoreFocusDialogClose is TabItem)`, but there might be other elements, where a re-focus is not desired?

I'd be happy to provide a PR after we agree on a solution.

Also - for now, I'd welcome any idea for a good workaround I could place into the application to make it work for now.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

DialogHost.cs の268行目付近から始め、ダイアログを開く TabControl、TabItem、SelectionChanging ハンドラーとのインタラクションを再現してください。タブ項目では、以前に選択されていた要素へのフォーカスの復元をスキップするべきか、別の方法で処理するべきかを調査し、ダイアログを閉じた後も新しく選択されたタブがアクティブなままになることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
desktop
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。