fix: improve shortcuts for German keyboard layout (#31647)
Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
This commit is contained in:
parent
4fd2c8c338
commit
8978d24f9d
2 changed files with 29 additions and 6 deletions
|
|
@ -95,6 +95,23 @@ function get_shortcut_for_key(key) {
|
|||
frappe.ui.keys.AltShortcutGroup = class AltShortcutGroup {
|
||||
constructor() {
|
||||
this.shortcuts_dict = {};
|
||||
|
||||
const locale = new Intl.Locale(navigator.language);
|
||||
// Skip certain Keys for different Languages on different Platforms
|
||||
switch (locale.language) {
|
||||
case "de":
|
||||
if (frappe.utils.is_mac()) {
|
||||
this.blacklisted_letters = ["e", "l"];
|
||||
} else {
|
||||
this.blacklisted_letters = ["q"];
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
this.blacklisted_letters = [];
|
||||
break;
|
||||
}
|
||||
|
||||
$current_dropdown = null;
|
||||
this.bind_events();
|
||||
frappe.ui.keys.bind_shortcut_group_event();
|
||||
|
|
@ -179,6 +196,10 @@ frappe.ui.keys.AltShortcutGroup = class AltShortcutGroup {
|
|||
let is_in_global_shortcut = frappe.ui.keys.standard_shortcuts
|
||||
.filter((s) => !s.page)
|
||||
.some((s) => s.shortcut === `alt+${letter}`);
|
||||
return letter in this.shortcuts_dict || is_in_global_shortcut;
|
||||
return (
|
||||
letter in this.shortcuts_dict ||
|
||||
is_in_global_shortcut ||
|
||||
this.blacklisted_letters.includes(letter.toLowerCase())
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -526,11 +526,13 @@ frappe.ui.Page = class Page {
|
|||
$li.addClass("user-action").insertBefore(this.divider);
|
||||
}
|
||||
|
||||
// alt shortcut
|
||||
frappe.ui.keys
|
||||
.get_shortcut_group(parent.get(0))
|
||||
.add($link, $link.find(".menu-item-label"));
|
||||
|
||||
// if an shortcut is already set, dont set an alt Shortcut
|
||||
if (!shortcut) {
|
||||
// alt shortcut
|
||||
frappe.ui.keys
|
||||
.get_shortcut_group(parent.get(0))
|
||||
.add($link, $link.find(".menu-item-label"));
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue