diff --git a/plugins/notes/frontend/src/index.js b/plugins/notes/frontend/src/index.js index 19035d0..3d2172a 100644 --- a/plugins/notes/frontend/src/index.js +++ b/plugins/notes/frontend/src/index.js @@ -178,6 +178,7 @@ var noteActions = []; var filterText = ''; var sortMode = 'title-asc'; + var renameTarget = null; function notesParent() { return workspaceRoot || ''; @@ -489,7 +490,7 @@ if (disposed) return; data = data || {}; if (data.conflict) { - showConflictModal(title, data.path); + showConflictModal(title, data.path, createInput); return; } hideCreate(); @@ -540,7 +541,7 @@ if (disposed) return; data = data || {}; if (data.conflict) { - showConflictModal(newTitle, data.path); + showConflictModal(newTitle, data.path, renameInput); return; } hideRename(); @@ -571,16 +572,17 @@ // ─── Conflict Modal ───────────────────────────────────── - function showConflictModal(title, existingPath) { + function showConflictModal(title, existingPath, focusTarget) { var overlay = el('div', { className: 'notes-modal-overlay' }); var modal = el('div', { className: 'notes-modal' }, [ el('div', { className: 'notes-modal-title' }, ['Name Conflict']), el('div', { className: 'notes-modal-msg' }, [ 'A note with the title "' + title + '" already exists.', + existingPath ? ' Existing file: ' + existingPath + '.' : '', ' Please choose a different title.' ].join('')), el('div', { className: 'notes-modal-actions' }, [ - el('button', { className: 'notes-modal-btn confirm', textContent: 'OK', onClick: function () { overlay.remove(); createInput.focus(); } }) + el('button', { className: 'notes-modal-btn confirm', textContent: 'OK', onClick: function () { overlay.remove(); (focusTarget || createInput).focus(); } }) ]) ]); overlay.appendChild(modal); diff --git a/scripts/smoke-notes-plugin.js b/scripts/smoke-notes-plugin.js index 3c07d5e..96c19ea 100755 --- a/scripts/smoke-notes-plugin.js +++ b/scripts/smoke-notes-plugin.js @@ -288,6 +288,25 @@ async function mountNotes(api) { sortSelect.value = 'title-asc'; sortSelect.dispatchEvent('change'); + const renameButton = walk(container, (node) => node.getAttribute && node.getAttribute('data-note-action') === 'rename'); + if (!renameButton) throw new Error('rename note button not found'); + renameButton.click(); + const renameInput = walk(container, (node) => node.getAttribute && node.getAttribute('data-notes-rename-input') !== undefined); + if (!renameInput) throw new Error('rename input not found'); + renameInput.value = 'Second Note'; + const renameConfirm = walk(container, (node) => node.tagName === 'BUTTON' && node.textContent === 'Rename'); + if (!renameConfirm) throw new Error('rename confirm button not found'); + renameConfirm.click(); + await flush(); + const conflictModal = walk(document.body, (node) => node.className === 'notes-modal-msg'); + if (!conflictModal || !conflictModal.textContent.includes('Project/Notes/Second_Note.md')) { + throw new Error(`rename conflict modal should include existing path, got ${conflictModal && conflictModal.textContent}`); + } + const conflictOk = walk(document.body, (node) => node.tagName === 'BUTTON' && node.textContent === 'OK'); + if (!conflictOk) throw new Error('rename conflict OK button not found'); + conflictOk.click(); + await flush(); + const providerAction = walk(container, (node) => node.getAttribute && node.getAttribute('data-note-contribution-action') === 'provider.note.action'); if (!providerAction) throw new Error('provider note action button not found'); providerAction.click();