Skip to content

Commit 9c281b8

Browse files
authored
Hitting ctrl+enter (or cmd on mac) executes the current query. (#45)
1 parent 2786cab commit 9c281b8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Explorer.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,12 @@ class ArgView extends React.PureComponent<ArgViewProps, ArgViewState> {
641641
}
642642

643643
function isRunShortcut(event) {
644-
return event.metaKey && event.key === 'Enter';
644+
return event.ctrlKey && event.key === 'Enter';
645+
}
646+
647+
function canRunOperation(operationName) {
648+
// it does not make sense to try to execute a fragment
649+
return operationName !== 'FragmentDefinition'
645650
}
646651

647652
type AbstractArgViewProps = {|
@@ -708,11 +713,6 @@ class ScalarInput extends React.PureComponent<ScalarInputProps, {}> {
708713
this._ref = ref;
709714
}}
710715
type="text"
711-
onKeyDown={event => {
712-
if (isRunShortcut(event)) {
713-
this.props.onRunOperation(event);
714-
}
715-
}}
716716
onChange={this._handleChange}
717717
value={value}
718718
/>
@@ -1513,7 +1513,7 @@ class RootView extends React.PureComponent<RootViewProps, {}> {
15131513
this.props.onOperationRename(event.target.value);
15141514

15151515
_handlePotentialRun = event => {
1516-
if (isRunShortcut(event)) {
1516+
if (isRunShortcut(event) && canRunOperation(this.props.definition.kind)) {
15171517
this.props.onRunOperation(this.props.name);
15181518
}
15191519
};
@@ -1555,7 +1555,9 @@ class RootView extends React.PureComponent<RootViewProps, {}> {
15551555
borderBottom: this.props.isLast ? 'none' : '1px solid #d6d6d6',
15561556
marginBottom: '0em',
15571557
paddingBottom: '1em',
1558-
}}>
1558+
}}
1559+
tabIndex='0'
1560+
onKeyDown={this._handlePotentialRun}>
15591561
<div style={{color: styleConfig.colors.keyword, paddingBottom: 4}}>
15601562
{operation}{' '}
15611563
<span style={{color: styleConfig.colors.def}}>

0 commit comments

Comments
 (0)