From af05b6761deed80feb6f151cb36d23b75421834c Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Wed, 9 Sep 2020 14:59:42 +0300 Subject: [PATCH] Save workspace when hitting Enter Signed-off-by: Alex Andreev --- .../components/+workspaces/workspaces.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/+workspaces/workspaces.tsx b/src/renderer/components/+workspaces/workspaces.tsx index fa7363dd9a..8efa4a1306 100644 --- a/src/renderer/components/+workspaces/workspaces.tsx +++ b/src/renderer/components/+workspaces/workspaces.tsx @@ -93,6 +93,12 @@ export class Workspaces extends React.Component { }) } + onInputKeypress = (evt: React.KeyboardEvent, workspaceId: WorkspaceId) => { + if (evt.key == 'Enter') { + this.saveWorkspace(workspaceId); + } + } + render() { return ( @@ -142,6 +148,7 @@ export class Workspaces extends React.Component { placeholder={_i18n._(t`Name`)} value={editingWorkspace.name} onChange={v => editingWorkspace.name = v} + onKeyPress={(e) => this.onInputKeypress(e, workspaceId)} autoFocus /> editingWorkspace.description = v} - /> - Cancel} - onClick={() => this.clearEditing(workspaceId)} + onKeyPress={(e) => this.onInputKeypress(e, workspaceId)} /> Save} onClick={() => this.saveWorkspace(workspaceId)} /> + Cancel} + onClick={() => this.clearEditing(workspaceId)} + /> )}