Fix language menu requiring two clicks in the Avalonia GUI#999
Open
gmipf wants to merge 1 commit into
Open
Conversation
The language MenuItems had no ToggleType, so clicking one never toggled its IsChecked state. The shared LanguageMenuItemClick handler reads IsChecked to tell a first selection from re-clicking the active language, so the first click only set IsChecked and returned; the language was applied only on the second click, and the active-language check mark never rendered. Add ToggleType="CheckBox" to the language items, mirroring the WPF GUI's IsCheckable="True" on the same items. This restores single-click switching and the check mark with no change to the handler. Co-Authored-By: Claude Opus 4.8 <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.
What
In the Avalonia GUI the title-bar language menu required two clicks to switch language — the first click did nothing visible, the second applied it. The active-language check mark also never appeared.
Cause
The WPF GUI's language
MenuItems useIsCheckable="True", which toggles the item'sIsCheckedstate on click before theClickhandler runs. The sharedLanguageMenuItemClickhandler relies on that: it readsIsCheckedto tell a fresh selection from re-clicking the already-active language (which it deliberately ignores, so the current language can't be deselected).The Avalonia port of the menu dropped the equivalent setting — Avalonia's
ToggleType— so clicking a language never toggledIsChecked. The handler's early-return branch (if (!clickedItem.IsChecked) { clickedItem.IsChecked = true; return; }) caught every initial click and returned; only the second click, withIsCheckednow true, applied the language. WithToggleTypeat its default ofNone, Avalonia also renders no check glyph, so the active language was never marked.Fix
Add
ToggleType="CheckBox"to the language items inMainWindow.axaml, mirroring the WPFIsCheckable="True". This restores the toggle-before-Click behaviour the shared handler already expects, so language switches on the first click and the active item shows a check mark. No code-behind change was needed.Testing
Prepared with AI assistance (Claude Opus 4.8) and reviewed before submission.