diff --git a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts index 573c520c9b..7fc58b7c74 100644 --- a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts +++ b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts @@ -761,14 +761,30 @@ describe("TableStructureEditor action column", () => { expect(copyTooltip?.getAttribute("delay-duration")).toBe("500"); expect(deleteTooltip?.getAttribute("delay-duration")).toBe("500"); expect(root.querySelector("[data-add-column-shortcut-content]")?.textContent).toBe("Shift+Enter"); - expect(root.querySelector("[data-copy-column-shortcut-content]")?.textContent).toBe("⌘/Ctrl+D"); - expect(root.querySelector("[data-delete-column-shortcut-content]")?.textContent?.trim()).toBe("⌘/Ctrl+Del"); + // The add control already renders its label, so that hint stays a bare shortcut. expect(root.querySelector("[data-add-column-shortcut-content]")?.textContent).not.toContain("structureEditor.addColumn"); - expect(root.querySelector("[data-copy-column-shortcut-content]")?.textContent).not.toContain("structureEditor.copyColumn"); + // The icon-only copy/delete controls must name the action next to the shortcut (#9870). + expect(root.querySelector("[data-copy-column-shortcut-content]")?.textContent).toBe("structureEditor.copyColumn⌘/Ctrl+D"); + expect(root.querySelector("[data-delete-column-shortcut-content]")?.textContent).toBe("structureEditor.drop⌘/Ctrl+Del"); expect(copyTooltip?.querySelector("button")?.hasAttribute("title")).toBe(false); expect(deleteTooltip?.querySelector("button")?.hasAttribute("title")).toBe(false); }); + it("names the delete control after the action it currently performs", async () => { + const root = await mountEditor("dameng"); + + const persistedDelete = root.querySelector('button[aria-label="structureEditor.drop"]'); + if (!persistedDelete) throw new Error("Missing delete button for the persisted column"); + persistedDelete.click(); + await vi.waitFor(() => expect(root.querySelector("[data-delete-column-shortcut-content]")?.textContent).toBe("structureEditor.restore⌘/Ctrl+Del")); + + buttonWithText(root, "structureEditor.addColumn").click(); + await vi.waitFor(() => expect(root.querySelector('[data-column-row-index="1"]')).not.toBeNull()); + const addedRow = root.querySelector('[data-column-row-index="1"]'); + expect(addedRow?.querySelector('button[aria-label="structureEditor.remove"]')).not.toBeNull(); + expect(addedRow?.querySelector("[data-delete-column-shortcut-content]")?.textContent).toBe("structureEditor.remove⌘/Ctrl+Del"); + }); + it("adds a field below the focused input on Shift+Enter", async () => { const root = await mountEditor("dameng"); const sourceInput = root.querySelector('[data-column-row-index="0"] [data-column-name-input]'); diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue index fc6dee7307..9013be198a 100644 --- a/apps/desktop/src/components/structure/TableStructureEditor.vue +++ b/apps/desktop/src/components/structure/TableStructureEditor.vue @@ -3774,6 +3774,17 @@ function columnContextMenuItems(column: EditableStructureColumn): ContextMenuIte ]; } +/** + * The delete control is icon-only and swaps between three actions, so its + * tooltip has to name the action instead of only showing the shortcut (#9870). + */ +function deleteColumnActionLabel(column: EditableStructureColumn): string { + if (!column.original) { + return t("structureEditor.remove"); + } + return column.markedForDrop ? t("structureEditor.restore") : t("structureEditor.drop"); +} + function isColumnNameDisabled(column: EditableStructureColumn): boolean { return column.markedForDrop || (!!column.original && !structureCapabilities.value.renameColumn); } @@ -5031,7 +5042,10 @@ watch( - ⌘/Ctrl+D + + {{ t("structureEditor.copyColumn") }} + ⌘/Ctrl+D + @@ -5043,8 +5057,9 @@ watch( - - {{ column.markedForDrop ? t("structureEditor.restore") : "⌘/Ctrl+Del" }} + + {{ deleteColumnActionLabel(column) }} + ⌘/Ctrl+Del diff --git a/docs/screenshots/issue-9870-column-action-copy-after.png b/docs/screenshots/issue-9870-column-action-copy-after.png new file mode 100644 index 0000000000..fb577276cf Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-copy-after.png differ diff --git a/docs/screenshots/issue-9870-column-action-copy-before.png b/docs/screenshots/issue-9870-column-action-copy-before.png new file mode 100644 index 0000000000..51e327537e Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-copy-before.png differ diff --git a/docs/screenshots/issue-9870-column-action-drop-after.png b/docs/screenshots/issue-9870-column-action-drop-after.png new file mode 100644 index 0000000000..8a6e1345a1 Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-drop-after.png differ diff --git a/docs/screenshots/issue-9870-column-action-drop-before.png b/docs/screenshots/issue-9870-column-action-drop-before.png new file mode 100644 index 0000000000..5b3430d68e Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-drop-before.png differ diff --git a/docs/screenshots/issue-9870-column-action-remove-after.png b/docs/screenshots/issue-9870-column-action-remove-after.png new file mode 100644 index 0000000000..9e01c494f3 Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-remove-after.png differ diff --git a/docs/screenshots/issue-9870-column-action-remove-before.png b/docs/screenshots/issue-9870-column-action-remove-before.png new file mode 100644 index 0000000000..86e9e3c1e9 Binary files /dev/null and b/docs/screenshots/issue-9870-column-action-remove-before.png differ