Skip to content

Fix language menu requiring two clicks in the Avalonia GUI#999

Open
gmipf wants to merge 1 commit into
SabreTools:masterfrom
gmipf:pr/5-language-menu-toggle
Open

Fix language menu requiring two clicks in the Avalonia GUI#999
gmipf wants to merge 1 commit into
SabreTools:masterfrom
gmipf:pr/5-language-menu-toggle

Conversation

@gmipf

@gmipf gmipf commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

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 use IsCheckable="True", which toggles the item's IsChecked state on click before the Click handler runs. The shared LanguageMenuItemClick handler relies on that: it reads IsChecked to 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 toggled IsChecked. The handler's early-return branch (if (!clickedItem.IsChecked) { clickedItem.IsChecked = true; return; }) caught every initial click and returned; only the second click, with IsChecked now true, applied the language. With ToggleType at its default of None, Avalonia also renders no check glyph, so the active language was never marked.

Fix

Add ToggleType="CheckBox" to the language items in MainWindow.axaml, mirroring the WPF IsCheckable="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

  • Full Avalonia project builds clean on net10.0 (0 warnings, 0 errors).
  • Manually verified on Fedora KDE (Avalonia, .NET 10): switching between English and German now takes a single click each way, the dropdown header updates, and the check mark tracks the active language.

Prepared with AI assistance (Claude Opus 4.8) and reviewed before submission.

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>
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.

1 participant