Proposal - Dont focus flyout on close #2671

Merged
merged 2 commits into from Sep 26, 2016

Conversation

Projects
None yet
2 participants
@ButchersBoy
Contributor

ButchersBoy commented Sep 26, 2016

Background

I have multiple windows, and i'm using flyouts to show an alert condition in the application. When the user dismisses the alert all flyouts are closed via my application code.

The problem

This line causes the last Window my where my code closes the flyout to receive focus , bringing that window to the front, interrupting the users activity:

// focus the Flyout itself to avoid nasty FocusVisual painting (it's visible until the Flyout is closed)        
flyout.Focus();

Remarks

I understand there is a specific comment here regarding this line to perform some visual trickery. However, it's not logically correct. I have experimented, removed the line, and I can't see any display issues in my application.

Maybe someone / @punker76 , with some background on this line can comment?

Another option would be to make the code a bit more specific; only run the focus if the current Window is active, something like:

if (Window.GetWindow(flyout) == Application.Windows.OfType<Window>().FirstOrDefault(w => w.IsActive))
    flyout.Focus();
@punker76

This comment has been minimized.

Show comment
Hide comment
@punker76

punker76 Sep 26, 2016

Member

@ButchersBoy This hack was introduced with #1805 by this issue (found by manual testing)

2016-09-26_22h22_18

2016-09-26_22h22_44

But now, I can't also not reproduce this with the current source, so I think we can change this.

Member

punker76 commented Sep 26, 2016

@ButchersBoy This hack was introduced with #1805 by this issue (found by manual testing)

2016-09-26_22h22_18

2016-09-26_22h22_44

But now, I can't also not reproduce this with the current source, so I think we can change this.

@punker76 punker76 added this to the 1.4.0 milestone Sep 26, 2016

@punker76 punker76 merged commit 073d731 into MahApps:develop Sep 26, 2016

1 check passed

continuous-integration/teamcity Finished TeamCity Build MahApps.Metro PullRequest :: MahApps.Metro PullRequests : Tests passed: 59
Details
@ButchersBoy

This comment has been minimized.

Show comment
Hide comment
@ButchersBoy

ButchersBoy Sep 27, 2016

Contributor

Cool! 👍

Contributor

ButchersBoy commented Sep 27, 2016

Cool! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment