Skip to content

Don't toggle a SettingsExpander when typing Space in a header TextBox - #21021

Merged
Dustin L. Howett (DHowett) merged 1 commit into
mainfrom
crutkas-fix-expander-header-space-toggle
Dec 3, 2026
Merged

Dustin L. Howett (DHowett) merged 1 commit into
mainfrom
crutkas-fix-expander-header-space-toggle

Conversation

@crutkas

@crutkas Clint Rutkas (crutkas) commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

If you typed in a space bar into the name field. the expander would flip vs putting in a space. This now allows a space to be put in.

If the expander is in focus and space is hit, it will expand / collapse still.

I manually validated put typing and expanding work now.

image

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 7ddaaec103494d9255e8b53665397416cc734312

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Verified by hand in Terminal Dev with a real keyboard: Space types, no toggle; header Space still toggles.
↑ Same result from a scripted UIA check; key handling for the header itself is unchanged.
↓ Background image path box and the "Add a new profile" split button in a header weren't checked by hand.
↓ No automated test; gamepad and Narrator not checked.
Diagnosis confidence 9.5/10 ↑ ButtonBase key handling acts on any Space/Enter that bubbles to it and marks KeyDown handled.
↑ Scripted check reproduced the toggle on the unfixed build and not on the fixed one.
Evidence fit 9.5/10 ↑ Exactly the reported symptom (Space in profile Name toggles the expander), reproduced and fixed on a Dev build.

Summary of the Pull Request

Typing Space in a TextBox that sits in a SettingsExpander header (profile Name, background image path) toggled the expander instead of typing the space.

References and Relevant Issues

Regressed by #20232 (background image path moved into the expander header) and #20336 (profile Name moved into an expander header).

Detailed Description of the Pull Request / Additional comments

The expander header is a ToggleButton, and everything in SettingsExpander.Content lives inside it. ButtonBase acts on any Space/Enter/GamepadA that bubbles up to it, not just keys aimed at itself, and marks the KeyDown handled, so the TextBox never gets the character.

The template's header ToggleButton is now SettingsExpanderHeaderButton, a ToggleButton subclass that only passes key events to the base class when OriginalSource is the button itself. Keys from hosted controls stay unhandled. Space/Enter on the header itself still toggles.

Validation Steps Performed

  • msbuild OpenConsole.slnx /p:Configuration=Debug /p:Platform=ARM64 "/t:Terminal\CascadiaPackage" /m: passed, deployed as Terminal Dev.
  • By hand in Terminal Dev: Space in Profiles > Windows PowerShell > Name types a space and doesn't toggle. Space on the header row still toggles.
  • Scripted the same check with UIA plus posted keys against both builds. Without the fix, Space/Enter in the Name box toggled the expander. With it they don't, and Space on the focused header still toggles.
  • No automated test added.

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

The expander's header ToggleButton treated Space/Enter bubbling up from controls hosted in the header (e.g. the profile Name box) as clicks, toggling the expander and swallowing the typed character. Use a ToggleButton subclass that only handles keys aimed at itself.
@DHowett
Dustin L. Howett (DHowett) marked this pull request as ready for review December 3, 2026 22:00
@github-project-automation github-project-automation Bot moved this to To Cherry Pick in 1.26 Servicing Pipeline Dec 3, 2026
@DHowett
Dustin L. Howett (DHowett) merged commit 8ab6c6d into main Dec 3, 2026
29 checks passed
@DHowett
Dustin L. Howett (DHowett) deleted the crutkas-fix-expander-header-space-toggle branch December 3, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Cherry Pick

Development

Successfully merging this pull request may close these issues.

2 participants