From e83b2ea2be07771df30d98cadf44edcfba772bd9 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 24 Oct 2016 23:57:44 -0400 Subject: [PATCH] Allow delete key without modifier as shortcut for deleting (closes #3455) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixed a minor bug in `iD.uiCmd` that was causing keyboard shortcuts like '⌘⌫' to convert to 'Ctrl+Backspace+' (note extra trailing '+') It affected only the tooltip display, not the key event binding. --- modules/operations/delete.js | 2 +- modules/ui/cmd.js | 2 +- test/spec/ui/cmd.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/operations/delete.js b/modules/operations/delete.js index 6c751978c..6b8042a22 100644 --- a/modules/operations/delete.js +++ b/modules/operations/delete.js @@ -77,7 +77,7 @@ export function operationDelete(selectedIDs, context) { operation.id = 'delete'; - operation.keys = [uiCmd('⌘⌫'), uiCmd('⌘⌦')]; + operation.keys = [uiCmd('⌘⌫'), uiCmd('⌘⌦'), uiCmd('⌦')]; operation.title = t('operations.delete.title'); diff --git a/modules/ui/cmd.js b/modules/ui/cmd.js index ba09c232e..af544523b 100644 --- a/modules/ui/cmd.js +++ b/modules/ui/cmd.js @@ -25,7 +25,7 @@ export function uiCmd(code) { for (var i = 0; i < code.length; i++) { if (code[i] in replacements) { - result += replacements[code[i]] + '+'; + result += replacements[code[i]] + (i < code.length - 1 ? '+' : ''); } else { result += code[i]; } diff --git a/test/spec/ui/cmd.js b/test/spec/ui/cmd.js index 5369d319d..0ff9f70b6 100644 --- a/test/spec/ui/cmd.js +++ b/test/spec/ui/cmd.js @@ -35,6 +35,7 @@ describe('iD.uiCmd', function () { it('changes keys to linux versions', function () { ua = 'Linux'; iD.Detect(true); // force redetection + expect(iD.uiCmd('⌘⌫')).to.eql('Ctrl+Backspace'); expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A'); expect(iD.uiCmd('⇧A')).to.eql('Shift+A'); expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A'); @@ -44,6 +45,7 @@ describe('iD.uiCmd', function () { it('changes keys to win versions', function () { ua = 'Win'; iD.Detect(true); // force redetection + expect(iD.uiCmd('⌘⌫')).to.eql('Ctrl+Backspace'); expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A'); expect(iD.uiCmd('⇧A')).to.eql('Shift+A'); expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');