Skip to content

Support disabled items in SelectionPrompt<T> - #2181

Closed
thomas-mathers wants to merge 1 commit into
spectreconsole:mainfrom
thomas-mathers:prototype/selectable-disabled-items
Closed

Support disabled items in SelectionPrompt<T>#2181
thomas-mathers wants to merge 1 commit into
spectreconsole:mainfrom
thomas-mathers:prototype/selectable-disabled-items

Conversation

@thomas-mathers

Copy link
Copy Markdown

Closes #2180.

Adds IDisableableSelectionItem<T>, a separate opt-in interface rather than new members on ISelectionItem<T> directly, so it stays additive on every target framework (including netstandard2.0, which can't represent default interface implementations). ListPromptItem<T> implements it alongside IMultiSelectionItem<T>, and a SelectionItemExtensions.Disable() extension keeps the call site unchanged:

prompt.AddChoice("Fireball").Disable();

A disabled item is styled with DisabledStyle and skipped during arrow-key navigation, search, and default-value selection, the same way group headers already are in Mode.Leaf.

Opening as a draft since I haven't heard back on the issue write-up yet, happy to take feedback on the API shape before marking ready.

Test plan

  • Builds clean across all four target frameworks (net8.0/net9.0/net10.0/netstandard2.0)
  • Existing test suite passes (756/756)
  • New tests added covering navigation skip, wrap-around skip, search exclusion, and default-value fallback for disabled items

Adds IDisableableSelectionItem<T>, a separate opt-in interface rather
than new members on ISelectionItem<T> directly, so it stays additive
on every target framework (including netstandard2.0, which can't
represent default interface implementations). ListPromptItem<T>
implements it alongside IMultiSelectionItem<T>, and a
SelectionItemExtensions.Disable() extension keeps the call site
unchanged: prompt.AddChoice("Fireball").Disable().

A disabled item is styled with DisabledStyle and skipped during
arrow-key navigation, search, and default-value selection, the same
way group headers already are in Mode.Leaf.

Closes spectreconsole#2180
@thomas-mathers

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@thomas-mathers
thomas-mathers marked this pull request as ready for review July 29, 2026 13:57
@patriksvensson

Copy link
Copy Markdown
Contributor

Any specific reason you closed this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support disabled/unselectable items in SelectionPrompt<T>

2 participants