-
Couldn't load subscription status.
- Fork 713
Default Choice inputs to first option when no placeholder is set and custom choice is disabled #11918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@copilot Additionally, only default to the first option if the type is choice and AllowCustomChoice is false. |
Added the AllowCustomChoice check in commit 3c7b0d8. Now the default value is only set when AllowCustomChoice is false, ensuring that inputs allowing custom values retain their flexibility. |
|
Cherry-picked commit 408dc5d in bae849c. This adds a test command "Choice with no placeholder" to the Stress playground that demonstrates the functionality with two inputs:
|
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11918Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11918" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements automatic default value selection for Choice inputs in the Aspire Dashboard interaction service. When a Choice input has no placeholder and doesn't allow custom choices, it now defaults to the first available option, improving user experience by ensuring a valid selection is always present.
Key Changes
- Modified
InputViewModel.SetInput()to automatically set Choice inputs to the first option when conditions are met - Added comprehensive test coverage with 9 new test cases covering various scenarios
- Added a demo command in the Stress playground to demonstrate the functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Aspire.Dashboard/Model/Interaction/InputViewModel.cs |
Core logic implementation for defaulting Choice inputs to first option |
tests/Aspire.Dashboard.Components.Tests/Model/InputViewModelTests.cs |
Comprehensive test suite covering all scenarios and edge cases |
playground/Stress/Stress.AppHost/InteractionCommands.cs |
Demo command for manual testing of the new functionality |
Comments suppressed due to low confidence (1)
tests/Aspire.Dashboard.Components.Tests/Model/InputViewModelTests.cs:1
- The title and message don't match the actual functionality. The title says 'Text request' and message says 'Provide your name' but this is testing choice inputs for dinner selection.
// Licensed to the .NET Foundation under one or more agreements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested in codespaces.
939b356 to
5318cf1
Compare
Fixes #11255
Summary
This PR implements automatic default value selection for
InputType.Choiceinputs when no placeholder is specified and custom choices are not allowed. When a Choice input doesn't have a placeholder text andAllowCustomChoiceis false, it now defaults to the first option's value, providing a better user experience by ensuring a valid selection is always present.Changes
Core Implementation
Modified
InputViewModel.SetInput()insrc/Aspire.Dashboard/Model/Interaction/InputViewModel.csto automatically set the value to the first option when:ChoiceTest Coverage
Added comprehensive test suite in
tests/Aspire.Dashboard.Components.Tests/Model/InputViewModelTests.cscovering:Demo Command
Added a test command in
playground/Stress/Stress.AppHost/InteractionCommands.csnamed "Choice with no placeholder" that demonstrates the functionality with two inputs:This allows manual testing and verification of the feature in the Stress playground.
Behavior
Before:
After (AllowCustomChoice = false, default):
With Placeholder (unchanged):
With AllowCustomChoice = true (no default):
Testing
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.