From 835683413cb5c4953af4517f8a8d65a9d73e234b Mon Sep 17 00:00:00 2001 From: skirtle <65301168+skirtles-code@users.noreply.github.com> Date: Thu, 5 Feb 2026 11:32:33 +0000 Subject: [PATCH] feat: tooltips for field values --- .../src/components/state/StateFieldViewer.vue | 21 ++++++++++++++++++- .../src/core/component/state/custom.ts | 4 ++-- .../src/core/component/state/process.ts | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/applet/src/components/state/StateFieldViewer.vue b/packages/applet/src/components/state/StateFieldViewer.vue index a26c03a5c..8f8f48e3d 100644 --- a/packages/applet/src/components/state/StateFieldViewer.vue +++ b/packages/applet/src/components/state/StateFieldViewer.vue @@ -80,6 +80,25 @@ const normalizedDisplayedValue = computed(() => { } }) +const valueTooltip = computed(() => { + const tooltip = { + content: '', + disabled: true, + html: true, + } + + if (type.value === 'custom') { + const tooltipText = (props.data.value as InspectorCustomState)?._custom?.tooltipText + + if (tooltipText) { + tooltip.content = tooltipText + tooltip.disabled = false + } + } + + return tooltip +}) + // normalized display children const normalizedDisplayedChildren = computed(() => { const { value, inherit, customType } = raw.value @@ -205,7 +224,7 @@ async function submitDrafting() { : - + function ${escape(name)}${args}`, - tooltipText: string.trim() ? `
${string}
` : null, + tooltipText: string.trim() ? `
${escape(string)}
` : null, }, } } @@ -249,7 +249,7 @@ export function getObjectDetails(object: Record) { type: stateTypeName?.toLowerCase(), stateTypeName, value, - ...raw ? { tooltipText: `${raw}` } : {}, + ...raw ? { tooltipText: `
${escape(raw)}
` } : {}, }, } } diff --git a/packages/devtools-kit/src/core/component/state/process.ts b/packages/devtools-kit/src/core/component/state/process.ts index eb38e2474..ac15c1bdf 100644 --- a/packages/devtools-kit/src/core/component/state/process.ts +++ b/packages/devtools-kit/src/core/component/state/process.ts @@ -3,7 +3,7 @@ import type { InspectorState } from '../types' import { camelize } from '@vue/devtools-shared' import { ensurePropertyExists, returnError } from '../utils' import { vueBuiltins } from './constants' -import { getPropType, getSetupStateType, toRaw } from './util' +import { escape, getPropType, getSetupStateType, toRaw } from './util' function mergeOptions( to: any, @@ -297,7 +297,7 @@ function processEventListeners(instance: VueAppInstance) { displayText: isDeclared ? '✅ Declared' : '⚠️ Not declared', key: isDeclared ? '✅ Declared' : '⚠️ Not declared', value: isDeclared ? '✅ Declared' : '⚠️ Not declared', - tooltipText: !isDeclared ? `The event ${eventName} is not declared in the emits option. It will leak into the component's attributes ($attrs).` : null, + tooltipText: !isDeclared ? `The event ${escape(eventName)} is not declared in the emits option. It will leak into the component's attributes ($attrs).` : null, }, }, })