diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-12-06 16:09:57 +0100 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2024-12-06 16:18:06 +0100 |
commit | 351fd02446dd9a5f9b1d6cbba51dc57be8f728ab (patch) | |
tree | 96b95ed01b412b2806d4b6c70c68ebdfab24786b | |
parent | ad045d6ede511d15da045e64cc0ee988fd945a9f (diff) | |
download | nextcloud-server-fix/files-rename-esc.tar.gz nextcloud-server-fix/files-rename-esc.zip |
fix(files): cancel renaming on enter if no file name changesfix/files-rename-esc
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 1eff841738b..2a727b55c29 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 77f23a00459..752e8264ceb 100644 --- a/cypress/e2e/files/files-renaming.cy.ts +++ b/cypress/e2e/files/files-renaming.cy.ts @@ -143,4 +143,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') + }) }) |