Skip to content

cmdpal: Support Enter key to submit FormContent (Adaptive Card) inputs - #48768

Merged
Michael Jolley (michaeljolley) merged 3 commits into
mainfrom
michaeljolley-cmdpal-enter-submit-form
Jul 1, 2026
Merged

cmdpal: Support Enter key to submit FormContent (Adaptive Card) inputs#48768
Michael Jolley (michaeljolley) merged 3 commits into
mainfrom
michaeljolley-cmdpal-enter-submit-form

Conversation

@michaeljolley

Copy link
Copy Markdown
Contributor

Summary

Adds Enter key support for submitting Adaptive Card forms in the Command Palette. When a user presses Enter inside a single-line Input.Text field, the form is automatically submitted using the first Action.Submit or Action.Execute action on the card.

Problem

When extensions use FormContent with Adaptive Cards, pressing Enter inside an Input.Text field does not trigger submission. Users must click the submit button with their mouse (or tab to it), breaking keyboard-only workflows like login/unlock forms.

Solution

Added a KeyDown event handler on the rendered Adaptive Card's FrameworkElement in ContentFormControl.xaml.cs:

  • Intercepts VirtualKey.Enter when the source is a TextBox that doesn't accept returns (single-line)
  • Finds the first AdaptiveSubmitAction or AdaptiveExecuteAction on the card
  • Calls HandleSubmit with that action and the current user inputs via RenderedAdaptiveCard.UserInputs.AsJson()

Multiline text inputs (AcceptsReturn = true) are excluded so Enter still inserts newlines.

Validation

  • Single file change in ContentFormControl.xaml.cs
  • Uses existing HandleSubmit path — same behavior as clicking the submit button
  • No impact on cards without submit/execute actions
  • No impact on multiline text inputs

Fixes #46003

When a user presses Enter inside a single-line TextBox within an
Adaptive Card form, find the first Submit or Execute action on the
card and trigger form submission with the current input values.

This enables keyboard-only form workflows (e.g. login/unlock forms
in extensions) without requiring users to click the submit button.

Multiline text inputs (AcceptsReturn=true) are excluded so that
Enter still inserts newlines in those fields.

Fixes #46003

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Product-Command Palette Refers to the Command Palette utility label Jun 21, 2026
AsJson() only returns values cached by a successful ValidateInputs() call, so the Enter-to-submit path was sending an empty payload. Validate (and gather) the inputs first, mirroring the renderer's button-click path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@michaeljolley
Michael Jolley (michaeljolley) marked this pull request as ready for review June 26, 2026 20:43
@michaeljolley Michael Jolley (michaeljolley) added the Needs-Review This Pull Request awaits the review of a maintainer. label Jun 26, 2026
Copy _renderedCard/_adaptiveCard into locals at the top of OnFormKeyDown so the resolved submit action and the gathered inputs come from the same card generation, hardening against any future re-entrancy from DisplayCard. Addresses PR review feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Image

@michaeljolley
Michael Jolley (michaeljolley) merged commit a43fb12 into main Jul 1, 2026
8 checks passed
@michaeljolley
Michael Jolley (michaeljolley) deleted the michaeljolley-cmdpal-enter-submit-form branch July 1, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Review This Pull Request awaits the review of a maintainer. Product-Command Palette Refers to the Command Palette utility

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

cmdpal: Support Enter key to submit FormContent (Adaptive Card) inputs

2 participants