Repository navigation
Dropdowns and single-selection lists can't be cleared by Ctrl+Space or Ctrl+click (#107) - #110
Merged
Merged
Conversation
Avalonia toggles the selected item of a ComboBox or ListBox off when it is picked again with the command modifier (Ctrl+Space, Ctrl+Enter, Ctrl+click; Cmd on macOS). A combo box was left empty and pushed null into settings that always hold a value, which threw NullReferenceException in the view models (e.g. TriggerGestureViewModel) and showed it under the combo box. - SingleSelectionGuard (registered in App.Initialize) swallows that toggle on the selected item of combo boxes and single-selection list boxes; an open drop-down closes as after any pick. Multi-selection lists keep the toggle. - Choices.Restore: every Choice<T> property (Triggers, Presets editor, General, Theme, Watch folders, rename rules) and the navigation selection ignore null and keep their previous value; the control then reads the bound value again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #107. Pressing Ctrl+Space twice on a focused dropdown threw a
NullReferenceException, shown as red text under the combo on the Shortcuts page and elsewhere.Cause (Avalonia 12.1.3):
SelectingItemsControl.UpdateSelectionFromEvent, which treats Ctrl (Cmd on macOS) as "toggle" and setsSelectedIndex = -1in single-selection mode.Choice<T>properties.The sidebar nav list had the same problem: Ctrl+clicking the current page made
CreatePage(null)fail.Fix
SingleSelectionGuardblocks toggle input on an already-selected item in ComboBoxes and single-selection ListBoxes. It covers the KeyDown, PointerPressed and PointerReleased tunnel handlers and uses Avalonia's own trigger and modifier checks. Arrows, Enter/Space to open, Ctrl+clicking another item and multi-select lists behave as before.Choices.Restoremakes everyChoice<T>and nav property keep its previous value when null arrives. The guard re-reads the binding so the control shows that value again.TriggerGestureViewModelPresetEditorViewModel(all combos)GeneralPageViewModelThemePageViewModelWatchRuleViewModelRenameStepViewModelMainWindowViewModelTest plan
6 new
SelectionGuardTests:Without the fix, 5 of them fail.
App 271 and Core 200 tests pass.
dotnet formatis clean.π€ Generated with Claude Code