Skip to content

Fix font face keyboard selection crash#20255

Merged
carlos-zamora merged 1 commit into
microsoft:mainfrom
danyalahmed1995:fix/20245-font-dropdown-enter-crash
Jun 22, 2026
Merged

Fix font face keyboard selection crash#20255
carlos-zamora merged 1 commit into
microsoft:mainfrom
danyalahmed1995:fix/20245-font-dropdown-enter-crash

Conversation

@danyalahmed1995

@danyalahmed1995 danyalahmed1995 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a crash in the Settings UI font face control when selecting a font suggestion with the keyboard and pressing Enter.

The font face AutoSuggestBox path was explicitly unfocusing the box after a chosen suggestion was submitted. During the keyboard suggestion commit path, that Focus(FocusState::Unfocused) call can trigger a WinUI/XAML crash before the settings model update completes.

This change avoids explicitly unfocusing the AutoSuggestBox in the chosen-suggestion path and instead commits the selected font and moves focus to the parent container.

Fixes #20245.

Validation

Manually validated with a local CascadiaPackage Debug x64 build:

  • Reproduced the crash before the fix.
  • Opened Settings → Defaults → Appearance → Font face.
  • Typed a partial font name.
  • Used arrow keys to select a suggestion.
  • Pressed Enter.
  • Verified Terminal no longer crashes.
  • Verified the selected font is applied and Save works.

@carlos-zamora

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@carlos-zamora carlos-zamora left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Tested this myself. This does fix the crash. Thank you so much for doing this!

This does unveil a new bug: #20353
But that bug definitely existed beforehand, it was just inaccessible (or more rare) due to the crash.
I'm fine with that for now. The bug is avoided if the user is using a mouse to move around.

@github-project-automation github-project-automation Bot moved this to To Cherry Pick in 1.25 Servicing Pipeline Jun 22, 2026
@github-project-automation github-project-automation Bot moved this to To Cherry Pick in 1.24 Servicing Pipeline Jun 22, 2026
@carlos-zamora carlos-zamora moved this from To Cherry Pick to To Consider in 1.24 Servicing Pipeline Jun 22, 2026
@carlos-zamora carlos-zamora moved this from To Cherry Pick to To Consider in 1.25 Servicing Pipeline Jun 22, 2026
@carlos-zamora
carlos-zamora merged commit d288fa0 into microsoft:main Jun 22, 2026
16 checks passed
@danyalahmed1995

Copy link
Copy Markdown
Contributor Author

@carlos-zamora No problem 🙂, I will check the issue #20353 and get back to you.

carlos-zamora pushed a commit that referenced this pull request Jun 30, 2026
## Summary

Fixes the font face `AutoSuggestBox` resetting to its previous value, or
stale filter text, after a keyboard-selected font is committed and focus
later leaves the control.

WinUI restores its cached user query when the suggestion list closes.
The existing `LostFocus` path then treated that programmatic restoration
as fresh user input and committed the stale value.

This change distinguishes genuine user edits from programmatic text
restoration, preserving the committed font value while retaining the
queued selected-suggestion commit introduced by #20255.

Fixes #20353.

## Validation

Manually validated with a local `CascadiaPackage` Debug x64 build:

- Reproduced the reset before the fix.
- Selected `Lucida Console` from `Consolas` using keyboard navigation.
- Pressed Enter and confirmed `Lucida Console` was applied.
- Returned focus to the Font face control and tabbed out again.
- Verified `Lucida Console` remained selected.
- Verified stale filter text did not return.
- Verified the #20245 crash did not regress.
- Verified Save and Discard changes both work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Consider
Status: To Consider

Development

Successfully merging this pull request may close these issues.

Crashes when pressing Enter after selecting a font from the font dropdown

2 participants