diff --git a/src/popup/views/settings.js b/src/popup/views/settings.js index ecbb038..535d38a 100644 --- a/src/popup/views/settings.js +++ b/src/popup/views/settings.js @@ -78,8 +78,8 @@ function renderWalletListSettings() { state.wallets.forEach((wallet, idx) => { const name = escapeHtml(wallet.name || "Wallet " + (idx + 1)); html += `
`; - html += `${name}`; - html += `[delete]`; + html += `${name}`; + html += ``; html += `
`; }); container.innerHTML = html; @@ -94,6 +94,38 @@ function renderWalletListSettings() { $("delete-wallet-confirm").classList.remove("hidden"); }); }); + + // Inline rename on click + container.querySelectorAll(".settings-wallet-name").forEach((span) => { + span.addEventListener("click", () => { + const idx = parseInt(span.dataset.idx, 10); + const wallet = state.wallets[idx]; + const input = document.createElement("input"); + input.type = "text"; + input.className = + "border border-border p-0 text-xs bg-bg text-fg w-full"; + input.value = wallet.name || "Wallet " + (idx + 1); + span.replaceWith(input); + input.focus(); + input.select(); + const finish = async () => { + const val = input.value.trim(); + if (val && val !== wallet.name) { + wallet.name = val; + await saveState(); + } + renderWalletListSettings(); + }; + input.addEventListener("blur", finish); + input.addEventListener("keydown", (e) => { + if (e.key === "Enter") input.blur(); + if (e.key === "Escape") { + input.value = wallet.name || "Wallet " + (idx + 1); + input.blur(); + } + }); + }); + }); } function show() {