diff --git a/src/lib/components/Action.svelte b/src/lib/components/Action.svelte
index d7de36aa..30fe727e 100644
--- a/src/lib/components/Action.svelte
+++ b/src/lib/components/Action.svelte
@@ -1,6 +1,7 @@
{#if display === "keys"}
-
+
{info.icon ?? info.id ?? `0x${info.code.toString(16)}`}
{:else if display === "inline-keys"}
{#if !info.icon && info.id?.length === 1}
{info.id}
{:else}
- {info.icon ?? info.id ?? `0x${info.code.toString(16)}`}
+ {info.icon ?? info.id ?? `0x${info.code.toString(16)}`}
{/if}
{/if}
diff --git a/src/lib/components/layout/KeyText.svelte b/src/lib/components/layout/KeyText.svelte
index 00f0ab86..9af757f1 100644
--- a/src/lib/components/layout/KeyText.svelte
+++ b/src/lib/components/layout/KeyText.svelte
@@ -5,6 +5,7 @@
import type {CompiledLayoutKey} from "$lib/serialization/visual-layout"
import {layout} from "$lib/undo-redo.js"
import {KEYMAP_CODES} from "$lib/serial/keymap-codes"
+ import {action} from "$lib/title"
const {fontSize, margin, inactiveOpacity, inactiveScale, iconFontSize} =
getContext("visual-layout-config")
@@ -22,7 +23,7 @@
{#each positions as position, layer}
{@const {action: actionId, isApplied} = $layout[layer][key.id] ?? {action: 0, isApplied: true}}
- {@const {code, icon, id} = KEYMAP_CODES[actionId] ?? {code: actionId}}
+ {@const {code, icon, id, title} = KEYMAP_CODES[actionId] ?? {code: actionId}}
{@const isActive = layer === $activeLayer}
{@const direction = [(middle[0] - margin * 3) / position[0], (middle[1] - margin * 3) / position[1]]}
{#if code !== 0}
{icon || id || `0x${code.toString(16)}`}
diff --git a/src/lib/title.ts b/src/lib/title.ts
index 7a7cab02..04af32e2 100644
--- a/src/lib/title.ts
+++ b/src/lib/title.ts
@@ -1,12 +1,12 @@
-import type { Action } from "svelte/action"
+import type {Action} from "svelte/action"
import tippy from "tippy.js"
-import type { SvelteComponent } from "svelte"
+import type {SvelteComponent} from "svelte"
import Tooltip from "$lib/components/Tooltip.svelte"
import hotkeys from "hotkeys-js"
-export const action: Action = (
- node: HTMLElement,
- { title, shortcut },
+export const action: Action = (
+ node: Element,
+ {title, shortcut},
) => {
let component: SvelteComponent | undefined
const tooltip = tippy(node, {
@@ -15,8 +15,8 @@ export const action: Action
animation: "fade",
onShow(instance) {
component ??= new Tooltip({
- target: instance.popper.querySelector(".tippy-content") as HTMLElement,
- props: { title, shortcut },
+ target: instance.popper.querySelector(".tippy-content") as Element,
+ props: {title, shortcut},
})
},
onHidden() {
@@ -25,8 +25,8 @@ export const action: Action
},
})
- if (shortcut) {
- hotkeys(shortcut, function(keyboardEvent) {
+ if (shortcut && node instanceof HTMLElement) {
+ hotkeys(shortcut, function (keyboardEvent) {
keyboardEvent.preventDefault()
node.click()
})