Skip to content

Fix focus not restored after Storage Pickers dialog closes#6544

Merged
DinahK-2SO merged 3 commits into
mainfrom
user/DinahK-2SO/storagepickers_focus_fix
Jun 11, 2026
Merged

Fix focus not restored after Storage Pickers dialog closes#6544
DinahK-2SO merged 3 commits into
mainfrom
user/DinahK-2SO/storagepickers_focus_fix

Conversation

@DinahK-2SO

@DinahK-2SO DinahK-2SO commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary:
Issue reported in #6505. Storage Pickers leave the WinUI window without keyboard focus after their dialog closes, so the keyboard stops working until the user clicks the window again.

Repro:

  1. in code map a button's Click handler with a picker behavior.
  2. Click the button (dialog opens), pick a file and confirm (dialog closes),
  3. then press Enter.
  4. Before the fix Enter does nothing;
    After the fix Enter re-invokes the button and the dialog reopens.

Fix:
An RAII helper DialogFocusRestorer captures the focused window before the dialog opens and restores focus to it once the dialog closes. Applied to all five pick methods.

The COM file dialog runs on a background thread, so SetFocus on close is ignored. Capture the focused window on the UI thread and marshal SetFocus back via the DispatcherQueue. Adds DialogFocusRestorer, applied to all five pick entry points.
@DinahK-2SO DinahK-2SO force-pushed the user/DinahK-2SO/storagepickers_focus_fix branch from cf215a8 to 4c101bb Compare June 10, 2026 07:36
@DinahK-2SO DinahK-2SO requested a review from Scottj1s June 10, 2026 07:50
@DinahK-2SO DinahK-2SO changed the title Fix keyboard focus not restored after Storage Pickers dialog closes Fix focus not restored after Storage Pickers dialog closes Jun 10, 2026
@DinahK-2SO

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO DinahK-2SO merged commit 5c22efb into main Jun 11, 2026
50 checks passed
@DinahK-2SO DinahK-2SO deleted the user/DinahK-2SO/storagepickers_focus_fix branch June 11, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants