Repository navigation
feat(defineShortcuts): add cursorTarget to scope the shortcut to specific element - #4169
Closed
J-Michalek wants to merge 2 commits into
Closed
J-Michalek wants to merge 2 commits into
J-Michalek wants to merge 2 commits into
Conversation
commit: |
cursorTarget to scope the shortcut to specific elementcursorTarget to scope the shortcut to specific element
Member
|
@J-Michalek Closing this as it brings too much complexity for something you can already achieve easily, here is an example: <script setup lang="ts">
import { useElementHover } from '@vueuse/core'
const cursorTarget = ref<HTMLElement | null>(null)
const isTargetHovered = useElementHover(cursorTarget)
const open = ref(false)
const shortcuts = computed(() => ({
i: isTargetHovered.value
? {
handler: () => {
open.value = !open.value
}
}
: undefined
}))
defineShortcuts(shortcuts)
</script>
<template>
<UPopover v-model:open="open">
<Placeholder ref="cursorTarget" class="size-48" />
<template #content>
<Placeholder class="size-48 m-4 inline-flex" />
</template>
</UPopover>
</template> |
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.
🔗 Linked issue
Resolves: #4165
❓ Type of change
📚 Description
I have added the option to specify which element can trigger the keyboard shortcut. This is useful when the user doesn't want to use a global shortcut but instead scope it to the
cursorTargetelement.📝 Checklist