Skip to content

AI-native design editor. Open-source Figma alternative.

fix(ui): prevent overlapping tooltips

Danila Poyarkova23e58d78550
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 81ecf45d7..ae014662e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,7 @@
- Match Figma auto-layout reflow after deleting children, hiding optional instance slots, or syncing component changes.
- Make group and boolean-operation children scale with their parent during resize.
- Restore desktop copy, cut, and paste when browser clipboard events are unavailable.
+- Show only the most specific tooltip when property controls contain nested actions.
- Start globally installed ACP agents correctly on Windows instead of reporting them as unavailable (#361).
- Keep duplicated layers independent instead of sharing mutable fills, strokes, bindings, overrides, or vector data, and remove stale bindings when paints are deleted.
- Preserve Hangul IME composition while editing text.
diff --git a/src/components/ui/Tip.vue b/src/components/ui/Tip.vue
index 80b7c6b5c..3355ee012 100644
--- a/src/components/ui/Tip.vue
+++ b/src/components/ui/Tip.vue
@@ -7,6 +7,7 @@ import { useTooltipUI } from '@/components/ui/tooltip'
const TOOLTIP_OPEN_DELAY_MS = 400
const TOOLTIP_SIDE_OFFSET = 4
const TOOLTIP_VIEWPORT_PADDING = 8
+const TOOLTIP_CLAIM_EVENT = 'open-pencil:tooltip-claim'
type TooltipSide = 'top' | 'bottom' | 'left' | 'right'
@@ -93,6 +94,11 @@ function refreshPosition() {
function show() {
if (!canOpen.value) return
+ document.dispatchEvent(
+ new CustomEvent(TOOLTIP_CLAIM_EVENT, {
+ detail: triggerRef.value
+ })
+ )
stopOpenTimer()
startOpenTimer()
}
@@ -102,12 +108,21 @@ function hide() {
open.value = false
}
+function isNestedTooltipEvent(event: PointerEvent | FocusEvent) {
+ const target = event.target
+ return target instanceof Element && target.closest('[data-tooltip-trigger]') !== triggerRef.value
+}
+
function containsRelatedTarget(event: PointerEvent | FocusEvent) {
const relatedTarget = event.relatedTarget
return relatedTarget instanceof Node && triggerRef.value?.contains(relatedTarget)
}
function onPointerOver(event: PointerEvent) {
+ if (isNestedTooltipEvent(event)) {
+ hide()
+ return
+ }
if (containsRelatedTarget(event)) return
show()
}
@@ -118,6 +133,10 @@ function onPointerOut(event: PointerEvent) {
}
function onFocusIn(event: FocusEvent) {
+ if (isNestedTooltipEvent(event)) {
+ hide()
+ return
+ }
if (containsRelatedTarget(event)) return
show()
}
@@ -131,10 +150,16 @@ function onPointerDown() {
hide()
}
+function onTooltipClaim(event: Event) {
+ if (!(event instanceof CustomEvent) || event.detail === triggerRef.value) return
+ hide()
+}
+
useEventListener(window, 'resize', refreshPosition)
useEventListener(window, 'scroll', refreshPosition, { capture: true, passive: true })
useEventListener(document, 'pointerdown', hide, { capture: true })
useEventListener(document, 'click', hide, { capture: true })
+useEventListener(document, TOOLTIP_CLAIM_EVENT, onTooltipClaim)
watch(canOpen, (value) => {
if (!value) hide()
@@ -144,6 +169,7 @@ watch(canOpen, (value) => {
<template>
<span
ref="triggerRef"
+ data-tooltip-trigger
class="contents"
@focusin="onFocusIn"
@focusout="onFocusOut"
diff --git a/tests/e2e/properties/panel.spec.ts b/tests/e2e/properties/panel.spec.ts
index c46d823e9..67927de59 100644
--- a/tests/e2e/properties/panel.spec.ts
+++ b/tests/e2e/properties/panel.spec.ts
@@ -68,6 +68,32 @@ test('appearance fields share control height and show variable actions', async (
expect(opacityBox.width).toBeGreaterThanOrEqual(40)
})
+test('property fields show only the most specific tooltip', async () => {
+ await editor.canvas.clearCanvas()
+ await editor.canvas.drawRect(200, 200, 80, 80)
+
+ const widthField = propertyField(editor.page, 'width')
+ const variableTrigger = widthField.getByRole('button', { name: 'Apply variable' })
+ const tooltips = editor.page.getByRole('tooltip')
+
+ await widthField.hover({ position: { x: 40, y: 12 } })
+ await expect(tooltips).toHaveText('Width')
+ await expect(tooltips).toHaveCount(1)
+
+ await variableTrigger.hover()
+ await expect(tooltips).toHaveText('Apply variable')
+ await expect(tooltips).toHaveCount(1)
+
+ await editor.page.mouse.move(500, 400)
+ await variableTrigger.focus()
+ await expect(tooltips).toHaveText('Apply variable')
+ await expect(tooltips).toHaveCount(1)
+
+ await propertyField(editor.page, 'height').hover({ position: { x: 40, y: 12 } })
+ await expect(tooltips).toHaveText('Height')
+ await expect(tooltips).toHaveCount(1)
+})
+
test('NumberField drag changes X position', async () => {
await editor.canvas.clearCanvas()
await editor.canvas.drawRect(100, 100, 80, 80)