MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit
Refocus after Dialog close triggers Tab change
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 16.3k
- 派生
- 3.5k
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 DialogHost.cs 大约第 268 行开始,复现与 TabControl、TabItem 以及打开对话框的 SelectionChanging 处理程序之间的交互。调查对于选项卡项,是否应跳过将焦点恢复到之前选中的元素,或以不同方式处理,并验证关闭对话框后新选中的选项卡仍处于活动状态。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- desktop
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100