mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 00:15:05 +01:00
fix(defineShortcuts): bring back meta to ctrl convert on non macos platforms
Resolves #3869, resolves #3318 Co-Authored-By: Sylvain Marroufin <marroufin.sylvain@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { ref, computed, toValue } from 'vue'
|
||||
import type { MaybeRef } from 'vue'
|
||||
import { useEventListener, useActiveElement, useDebounceFn } from '@vueuse/core'
|
||||
import { useKbd } from './useKbd'
|
||||
|
||||
type Handler = (e?: any) => void
|
||||
|
||||
@@ -66,6 +67,7 @@ export function defineShortcuts(config: MaybeRef<ShortcutsConfig>, options: Shor
|
||||
}
|
||||
const debouncedClearChainedInput = useDebounceFn(clearChainedInput, options.chainDelay ?? 800)
|
||||
|
||||
const { macOS } = useKbd()
|
||||
const activeElement = useActiveElement()
|
||||
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
@@ -178,6 +180,12 @@ export function defineShortcuts(config: MaybeRef<ShortcutsConfig>, options: Shor
|
||||
}
|
||||
shortcut.chained = chained
|
||||
|
||||
// Convert Meta to Ctrl for non-MacOS
|
||||
if (!macOS.value && shortcut.metaKey && !shortcut.ctrlKey) {
|
||||
shortcut.metaKey = false
|
||||
shortcut.ctrlKey = true
|
||||
}
|
||||
|
||||
// Retrieve handler function
|
||||
if (typeof shortcutConfig === 'function') {
|
||||
shortcut.handler = shortcutConfig
|
||||
|
||||
Reference in New Issue
Block a user