Skip to content

Conversation

corvinsz
Copy link
Member

@corvinsz corvinsz commented Sep 13, 2025

fixes #3434

The fix is basically to listen for the StateChanged event of the parent Window.
If the window is restored from the minimized state, we focus the previously focused element, which got stored in a field _lastFocusedDialogElement when the window got minimized.

I want to point out the artificial delay I added, that we have in other places in the DialogHost class too. I just couldn't get it to work without the (50ms) delay, as described in my comment above the "hacky" code.

...
// Kinda hacky, but without a delay the focus doesn't always get set correctly because the Focus() method fires too early
Task.Delay(50).ContinueWith(_ => this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
...

@corvinsz corvinsz closed this Sep 13, 2025
@corvinsz corvinsz reopened this Sep 13, 2025
@corvinsz
Copy link
Member Author

It seems like there is a problem with running the tests via github actions. This PR just had another failing test (SplitButton_WithButtonInPopup_CanBeInvoked). When reran, the test passed.
I'm not sure if this is a TUnit or github actions problem?

I had the same issue in #3915

@corvinsz corvinsz mentioned this pull request Sep 16, 2025
LGTM, thank you for the review!

Co-authored-by: Kevin B <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DialogHost accessibility issue
2 participants