MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

Refocus after Dialog close triggers Tab change

Đang mở
#1,121 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement evaluation required
Ngôn ngữ chính
C#
Star
16.3k
Fork
3.5k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
8

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại DialogHost.cs quanh dòng 268 và tái hiện tương tác với một TabControl, TabItem và trình xử lý SelectionChanging mở một hộp thoại. Điều tra xem có nên bỏ qua hoặc xử lý khác việc khôi phục tiêu điểm về phần tử đã được chọn trước đó đối với các mục tab hay không, đồng thời xác minh rằng việc đóng hộp thoại để lại tab mới được chọn ở trạng thái hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
desktop
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.