Skip to content

Commit 78a6c4c

Browse files
committed
Add Ctrl/Cmd+Enter Send shortcut
1 parent 70a5a9d commit 78a6c4c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/components/send/request-pane.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { RequestInput } from '../../model/send/send-request-model';
1212
import { EditableContentType } from '../../model/events/content-types';
1313

1414
import { ContainerSizedEditor } from '../editor/base-editor';
15+
import { useHotkeys } from '../../util/ui';
1516

1617
import { SendCardContainer } from './send-card-section';
1718
import { SendRequestLine } from './send-request-line';
@@ -33,7 +34,17 @@ const METHODS_WITHOUT_BODY = [
3334
'GET',
3435
'HEAD',
3536
'OPTIONS'
36-
]
37+
];
38+
39+
const RequestPaneKeyboardShortcuts = (props: {
40+
sendRequest: () => void
41+
}) => {
42+
useHotkeys('Ctrl+Enter, Cmd+Enter', (event) => {
43+
props.sendRequest()
44+
}, [props.sendRequest]);
45+
46+
return null;
47+
};
3748

3849
@inject('rulesStore')
3950
@inject('uiStore')
@@ -75,6 +86,10 @@ export class RequestPane extends React.Component<{
7586
return <SendCardContainer
7687
hasExpandedChild={!!uiStore?.expandedSendRequestCard}
7788
>
89+
<RequestPaneKeyboardShortcuts
90+
sendRequest={this.sendRequest}
91+
/>
92+
7893
<SendRequestLine
7994
method={requestInput.method}
8095
updateMethod={this.updateMethod}

src/components/send/send-request-line.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { Method } from 'mockttp';
44
import { styled } from '../../styles';
55
import { Icon, ArrowIcon } from '../../icons';
66

7-
import { Button, Select, TextInput } from '../common/inputs';
87
import { getMethodColor } from '../../model/events/categorization';
98

9+
import { Ctrl } from '../../util/ui';
10+
import { Button, Select, TextInput } from '../common/inputs';
11+
1012
type MethodName = keyof typeof Method;
1113
const validMethods = Object.values(Method)
1214
.filter(
@@ -160,7 +162,7 @@ export const SendRequestLine = (props: {
160162
<SendButton
161163
type='submit'
162164
disabled={props.isSending}
163-
title='Send this request'
165+
title={`Send this request (${Ctrl}+Enter)`}
164166
>
165167
{ props.isSending
166168
? <Icon spin fixedWidth={true} icon={['fas', 'spinner']} />

0 commit comments

Comments
 (0)