Skip to content

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

Fix double-click rename in layer tree and pages panel

Danila Poyarkov5cd7cc12b249
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 267b28247..ab0c006ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@
- JSX and Tailwind CSS export for grid layouts — `grid grid-cols-N`, `gap-x-*`/`gap-y-*`, child `col-start-*`/`row-start-*`/`col-span-*`/`row-span-*`
- Multi-provider AI support — connect to Anthropic, OpenAI, Google AI, or any OpenAI-compatible endpoint directly, in addition to OpenRouter. Per-provider API key storage, provider settings popover, automatic migration from single OpenRouter key
+### Fixes
+
+- Double-click on layer tree no longer toggles expand/collapse — use the chevron instead
+- Page rename input matches layer rename styling
+
### Improvements
- Compact layout controls — icon-based gap (↔/↕) and padding (T/R/B/L) inputs instead of text labels
diff --git a/src/components/LayerTree.vue b/src/components/LayerTree.vue
index cf21dbbbc..88e4ec661 100644
--- a/src/components/LayerTree.vue
+++ b/src/components/LayerTree.vue
@@ -279,18 +279,33 @@ function updateDropTarget(ev: PointerEvent) {
:data-node-id="item.value.id"
:data-level="item.level"
>
- <TreeItem v-slot="{ isExpanded }" v-bind="item.bind" as-child @select="onSelect">
+ <TreeItem
+ v-slot="{ isExpanded }"
+ v-bind="item.bind"
+ as-child
+ @select="onSelect"
+ @toggle="(e: CustomEvent) => { if (e.detail.originalEvent?.type === 'click') e.preventDefault() }"
+ >
<div
v-if="rename.editingId.value === item.value.id"
class="flex w-full items-center gap-1 py-1"
:style="{ paddingLeft: `${8 + (item.level - 1) * 16}px` }"
>
- <span class="w-4 shrink-0" />
+ <span
+ v-if="item.hasChildren"
+ class="flex w-4 shrink-0 cursor-pointer items-center justify-center text-muted transition-transform hover:text-surface"
+ :class="isExpanded ? 'rotate-90' : 'rotate-0'"
+ @click.stop="toggleExpand(item.value.id)"
+ >
+ <icon-lucide-chevron-right class="size-3" />
+ </span>
+ <span v-else class="w-4 shrink-0" />
<component
:is="nodeIcons[item.value.type] ?? IconSquare"
class="size-3 shrink-0 opacity-70"
/>
<input
+ :ref="(el) => { if (el) rename.focusInput(el as HTMLInputElement) }"
data-layer-edit
data-test-id="layers-item-input"
class="min-w-0 flex-1 rounded border border-accent bg-input px-1 py-0 text-xs text-surface outline-none"
diff --git a/src/components/PagesPanel.vue b/src/components/PagesPanel.vue
index 7995e775b..9295218c7 100644
--- a/src/components/PagesPanel.vue
+++ b/src/components/PagesPanel.vue
@@ -54,15 +54,20 @@ function startRename(pg: { id: string; name: string }) {
</div>
<div class="overflow-x-hidden overflow-y-auto scrollbar-thin px-1 pb-1">
<div v-for="pg in pages" :key="pg.id">
- <input
+ <div
v-if="rename.editingId.value === pg.id"
- :ref="(el) => setPageInputRef(pg.id, el as HTMLInputElement | null)"
- data-test-id="pages-item-input"
- class="w-full rounded border border-accent bg-input px-2 py-1 text-xs text-surface outline-none"
- :value="pg.name"
- @blur="rename.commit(pg.id, $event.target as HTMLInputElement)"
- @keydown="rename.onKeydown"
- />
+ class="flex w-full items-center gap-1.5 rounded px-2 py-1"
+ >
+ <icon-lucide-file class="size-3 shrink-0 opacity-70" />
+ <input
+ :ref="(el) => setPageInputRef(pg.id, el as HTMLInputElement | null)"
+ data-test-id="pages-item-input"
+ class="min-w-0 flex-1 rounded border border-accent bg-input px-1 py-0 text-xs text-surface outline-none"
+ :value="pg.name"
+ @blur="rename.commit(pg.id, $event.target as HTMLInputElement)"
+ @keydown="rename.onKeydown"
+ />
+ </div>
<div
v-else-if="isDivider(pg)"
class="my-1 flex items-center px-2"
diff --git a/src/composables/use-inline-rename.ts b/src/composables/use-inline-rename.ts
index 183d0d2f2..447ac077a 100644
--- a/src/composables/use-inline-rename.ts
+++ b/src/composables/use-inline-rename.ts
@@ -1,8 +1,11 @@
-import { nextTick, ref } from 'vue'
+import { nextTick, ref, type Ref } from 'vue'
+import { onClickOutside } from '@vueuse/core'
export function useInlineRename<T extends string>(onCommit: (id: T, newName: string) => void) {
const editingId = ref<T | null>(null)
+ const inputRef: Ref<HTMLInputElement | null> = ref(null)
let originalName = ''
+ let cleanupOutsideClick: (() => void) | undefined
function start(id: T, currentName: string) {
editingId.value = id
@@ -10,6 +13,12 @@ export function useInlineRename<T extends string>(onCommit: (id: T, newName: str
}
async function focusInput(input: HTMLInputElement | null) {
+ if (input === inputRef.value) return
+ inputRef.value = input
+ cleanupOutsideClick?.()
+ if (input) {
+ cleanupOutsideClick = onClickOutside(inputRef, () => input.blur())
+ }
await nextTick()
input?.focus()
input?.select()
@@ -22,10 +31,16 @@ export function useInlineRename<T extends string>(onCommit: (id: T, newName: str
onCommit(id, value)
}
editingId.value = null
+ inputRef.value = null
+ cleanupOutsideClick?.()
+ cleanupOutsideClick = undefined
}
function cancel() {
editingId.value = null
+ inputRef.value = null
+ cleanupOutsideClick?.()
+ cleanupOutsideClick = undefined
}
function onKeydown(e: KeyboardEvent) {
diff --git a/tests/e2e/layers-panel.spec.ts b/tests/e2e/layers-panel.spec.ts
index 9fed53448..e93d12ac6 100644
--- a/tests/e2e/layers-panel.spec.ts
+++ b/tests/e2e/layers-panel.spec.ts
@@ -156,3 +156,57 @@ test('ungrouping updates layers', async () => {
canvas.assertNoErrors()
})
+
+test('double-click layer to rename', async () => {
+ await canvas.drawRect(900, 600, 50, 50)
+ await canvas.waitForRender()
+
+ const row = layerRows().filter({ hasText: 'Rectangle' }).first()
+ await row.dblclick()
+
+ const input = page.locator('[data-test-id="layers-item-input"]')
+ await expect(input).toBeVisible()
+ await input.fill('Renamed Layer')
+ await input.press('Enter')
+
+ await canvas.waitForRender()
+ const names = await getLayerNames()
+ expect(names).toContain('Renamed Layer')
+
+ canvas.assertNoErrors()
+})
+
+test('clicking outside rename input commits', async () => {
+ const row = layerRows().filter({ hasText: 'Renamed Layer' }).first()
+ await row.dblclick()
+
+ const input = page.locator('[data-test-id="layers-item-input"]')
+ await expect(input).toBeVisible()
+ await input.fill('After Outside Click')
+
+ await page.mouse.click(500, 400)
+ await canvas.waitForRender()
+
+ await expect(input).not.toBeVisible()
+ const names = await getLayerNames()
+ expect(names).toContain('After Outside Click')
+
+ canvas.assertNoErrors()
+})
+
+test('double-click does not toggle tree expand', async () => {
+ const rowCountBefore = await layerRows().count()
+
+ const containerRow = layerRows().filter({ hasText: 'Components' }).first()
+ await containerRow.dblclick()
+ await canvas.waitForRender()
+
+ const input = page.locator('[data-test-id="layers-item-input"]')
+ await expect(input).toBeVisible()
+ await input.press('Escape')
+
+ const rowCountAfter = await layerRows().count()
+ expect(rowCountAfter).toBe(rowCountBefore)
+
+ canvas.assertNoErrors()
+})
diff --git a/tests/e2e/multi-page.spec.ts b/tests/e2e/multi-page.spec.ts
index 766bb8dbf..a14e94c8f 100644
--- a/tests/e2e/multi-page.spec.ts
+++ b/tests/e2e/multi-page.spec.ts
@@ -152,6 +152,40 @@ test('rename page via store', async () => {
canvas.assertNoErrors()
})
+test('double-click page to rename', async () => {
+ const item = pageItems().first()
+ await item.dblclick()
+
+ const input = page.locator('[data-test-id="pages-item-input"]')
+ await expect(input).toBeVisible()
+ await input.fill('My Page')
+ await input.press('Enter')
+
+ await canvas.waitForRender()
+ const pages = await getPages()
+ expect(pages.some((p) => p.name === 'My Page')).toBe(true)
+
+ canvas.assertNoErrors()
+})
+
+test('clicking outside page rename input commits', async () => {
+ const item = pageItems().first()
+ await item.dblclick()
+
+ const input = page.locator('[data-test-id="pages-item-input"]')
+ await expect(input).toBeVisible()
+ await input.fill('Outside Click Page')
+
+ await page.mouse.click(500, 400)
+ await canvas.waitForRender()
+
+ await expect(input).not.toBeVisible()
+ const pages = await getPages()
+ expect(pages.some((p) => p.name === 'Outside Click Page')).toBe(true)
+
+ canvas.assertNoErrors()
+})
+
test('cannot delete the last page', async () => {
// Delete until 1 remains
let pages = await getPages()