diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-12-06 16:09:57 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-12-12 18:25:03 +0100 |
commit | 0d5cda8aa4d13b46200eb58a25e89e40992a9c18 (patch) | |
tree | 52e3a784d01e4bfafe3f8f0ac0cfbdd28e996ff6 | |
parent | 5df643cf370dd60f32e81d6eb560fa38596195d1 (diff) | |
download | nextcloud-server-0d5cda8aa4d13b46200eb58a25e89e40992a9c18.tar.gz nextcloud-server-0d5cda8aa4d13b46200eb58a25e89e40992a9c18.zip |
fix(files): cancel renaming on enter if no file name changes
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
-rw-r--r-- | apps/files/src/components/FileEntry/FileEntryName.vue | 4 | ||||
-rw-r--r-- | cypress/e2e/files/files-renaming.cy.ts | 39 |
2 files changed, 43 insertions, 0 deletions
diff --git a/apps/files/src/components/FileEntry/FileEntryName.vue b/apps/files/src/components/FileEntry/FileEntryName.vue index 34b134f39ba..446b8c77739 100644 --- a/apps/files/src/components/FileEntry/FileEntryName.vue +++ b/apps/files/src/components/FileEntry/FileEntryName.vue @@ -241,6 +241,10 @@ export default defineComponent({ } const oldName = this.source.basename + if (newName === oldName) { + this.stopRenaming() + return + } try { const status = await this.renamingStore.rename() diff --git a/cypress/e2e/files/files-renaming.cy.ts b/cypress/e2e/files/files-renaming.cy.ts index fcf455c4d2e..140458305b9 100644 --- a/cypress/e2e/files/files-renaming.cy.ts +++ b/cypress/e2e/files/files-renaming.cy.ts @@ -140,4 +140,43 @@ describe('files: Rename nodes', { testIsolation: true }, () => { .findByRole('textbox', { name: 'Filename' }) .should('not.exist') }) + + it('cancel renaming on esc press', () => { + // All are visible by default + getRowForFile('file.txt').should('be.visible') + + triggerActionForFile('file.txt', 'rename') + + getRowForFile('file.txt') + .findByRole('textbox', { name: 'Filename' }) + .should('be.visible') + .type('{selectAll}other.txt') + .should(haveValidity('')) + .type('{esc}') + + // See it is not renamed + getRowForFile('other.txt').should('not.exist') + getRowForFile('file.txt') + .should('be.visible') + .find('input[type="text"]') + .should('not.exist') + }) + + it('cancel on enter if no new name is entered', () => { + // All are visible by default + getRowForFile('file.txt').should('be.visible') + + triggerActionForFile('file.txt', 'rename') + + getRowForFile('file.txt') + .findByRole('textbox', { name: 'Filename' }) + .should('be.visible') + .type('{enter}') + + // See it is not renamed + getRowForFile('file.txt') + .should('be.visible') + .find('input[type="text"]') + .should('not.exist') + }) }) |