Skip to content

keyboardManager: don't append locale layout if already present#13616

Merged
mtwebster merged 2 commits intolinuxmint:masterfrom
Fizmatik:fix/keyboard-duplicate-locale-layout
Mar 12, 2026
Merged

keyboardManager: don't append locale layout if already present#13616
mtwebster merged 2 commits intolinuxmint:masterfrom
Fizmatik:fix/keyboard-duplicate-locale-layout

Conversation

@Fizmatik
Copy link
Contributor

@Fizmatik Fizmatik commented Mar 3, 2026

Problem

_buildGroupStrings() in js/ui/keyboardManager.js unconditionally appends the locale-derived layout (from _getLocaleLayout()) to every XKB group via .concat(this._localeLayoutInfo).

When the user's configured layouts already include the locale layout (e.g. ru layout with ru_RU.UTF-8 locale), this produces duplicates — setxkbmap reports us,ru,ru instead of us,ru, adding a phantom third layout to the switcher.

This affects all users whose system locale matches one of their configured keyboard layouts (common for Russian, Ukrainian, German, French, and many other non-English locales).

Steps to reproduce

  1. Set system locale to ru_RU.UTF-8 (or any non-English locale)
  2. Configure keyboard layouts: English (US) + Russian
  3. Check with setxkbmap -query

Expected: layout: us,ru
Actual: layout: us,ru,ru

Fix

Check whether the locale layout is already present in the group before appending it. This preserves the original intent (ensuring a locale layout slot is always available for toolkit mnemonics) while avoiding duplication.

Testing

Tested on Linux Mint 22 Cinnamon (cinnamon 6.6.7, locale ru_RU.UTF-8). After the fix, setxkbmap -query correctly reports us,ru and the layout switcher shows exactly two layouts.

_buildGroupStrings() unconditionally appends the locale-derived layout
to the XKB group. When the user's configured layouts already include
the locale layout (e.g. 'ru' with ru_RU.UTF-8 locale), this produces
duplicates like 'us,ru,ru', adding a phantom third layout to the
switcher.

Check whether the locale layout is already present before appending it.
Address code review feedback: rename `dominated` to `alreadyIncluded`
for better self-description of the boolean's purpose.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mtwebster mtwebster merged commit b0c6e1f into linuxmint:master Mar 12, 2026
5 checks passed
@mtwebster
Copy link
Member

Thanks, Claude likes using that variable name for some reason... I can't imagine what content it trained on to get that impression.

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.

2 participants