fix/send request shortcut issue (#7993)

This commit is contained in:
shubh-bruno
2026-05-14 13:14:54 +05:30
committed by GitHub
parent 31dedc3c95
commit 9190de53ad
3 changed files with 33 additions and 15 deletions

View File

@@ -64,13 +64,16 @@ class CodeEditor extends React.Component {
componentDidMount() { componentDidMount() {
const variables = getAllVariables(this.props.collection, this.props.item); const variables = getAllVariables(this.props.collection, this.props.item);
const runShortcut = () => { /**
if (this.props.onRun) { * No-op. We claim Cmd-Enter / Ctrl-Enter here only to suppress CodeMirror's
this.props.onRun(); * sublime keymap default (insertLineAfter), which would otherwise insert a
return; * newline. sendRequest dispatch is owned by Mousetrap — the editor input has
} * the `mousetrap` class (added below) so the global
return CodeMirror.Pass; * useKeybinding('sendRequest', …) in RequestTabPanel handles it, and only
}; * in request tabs. Falling through with CodeMirror.Pass when onRun is absent
* would re-introduce the newline in collection/folder-level editors.
*/
const runShortcut = () => {};
const editor = (this.editor = CodeMirror(this._node, { const editor = (this.editor = CodeMirror(this._node, {
value: this.props.value || '', value: this.props.value || '',

View File

@@ -30,13 +30,16 @@ class MultiLineEditor extends Component {
// Initialize CodeMirror as a single line editor // Initialize CodeMirror as a single line editor
/** @type {import("codemirror").Editor} */ /** @type {import("codemirror").Editor} */
const variables = getAllVariables(this.props.collection, this.props.item); const variables = getAllVariables(this.props.collection, this.props.item);
const runShortcut = () => { /**
if (this.props.onRun) { * No-op. We claim Cmd-Enter / Ctrl-Enter here only to suppress CodeMirror's
this.props.onRun(); * sublime keymap default (insertLineAfter), which would otherwise insert a
return; * newline. sendRequest dispatch is owned by Mousetrap — the editor input has
} * the `mousetrap` class (added below) so the global
return CodeMirror.Pass; * useKeybinding('sendRequest', …) in RequestTabPanel handles it, and only
}; * in request tabs. Falling through with CodeMirror.Pass when onRun is absent
* would re-introduce the newline in collection/folder-level editors.
*/
const runShortcut = () => {};
this.editor = CodeMirror(this.editorRef.current, { this.editor = CodeMirror(this.editorRef.current, {
lineWrapping: false, lineWrapping: false,

View File

@@ -53,6 +53,16 @@ export default class QueryEditor extends React.Component {
} }
componentDidMount() { componentDidMount() {
/**
* No-op. We claim Cmd-Enter / Ctrl-Enter here only to suppress CodeMirror's
* sublime keymap default (insertLineAfter), which would otherwise insert a
* newline. sendRequest dispatch is owned by Mousetrap — the editor input has
* the `mousetrap` class (added below) so the global
* useKeybinding('sendRequest', …) in RequestTabPanel handles it, and only
* in request tabs.
*/
const runShortcut = () => {};
const editor = (this.editor = CodeMirror(this._node, { const editor = (this.editor = CodeMirror(this._node, {
value: this.props.value || '', value: this.props.value || '',
lineNumbers: true, lineNumbers: true,
@@ -125,7 +135,9 @@ export default class QueryEditor extends React.Component {
} }
}, },
'Cmd-F': 'findPersistent', 'Cmd-F': 'findPersistent',
'Ctrl-F': 'findPersistent' 'Ctrl-F': 'findPersistent',
'Cmd-Enter': runShortcut,
'Ctrl-Enter': runShortcut
} }
})); }));
if (editor) { if (editor) {