Skip to content

Commit a438c06

Browse files
sanish-brunohelloanoop
authored andcommitted
fix: remove duplicate search components
1 parent 4977dbe commit a438c06

File tree

1 file changed

+15
-1
lines changed
  • packages/bruno-app/src/components/CodeEditor

1 file changed

+15
-1
lines changed

packages/bruno-app/src/components/CodeEditor/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ if (!SERVER_RENDERED) {
8383
'bru.runner',
8484
'bru.runner.setNextRequest(requestName)',
8585
'bru.runner.skipRequest()',
86-
'bru.runner.stopExecution()',
86+
'bru.runner.stopExecution()'
8787
];
8888
CodeMirror.registerHelper('hint', 'brunoJS', (editor, options) => {
8989
const cursor = editor.getCursor();
@@ -174,11 +174,21 @@ export default class CodeEditor extends React.Component {
174174
}
175175
},
176176
'Cmd-F': (cm) => {
177+
if (this._isSearchOpen()) {
178+
// replace the older search component with the new one
179+
const search = document.querySelector('.CodeMirror-dialog.CodeMirror-dialog-top');
180+
search && search.remove();
181+
}
177182
cm.execCommand('findPersistent');
178183
this._bindSearchHandler();
179184
this._appendSearchResultsCount();
180185
},
181186
'Ctrl-F': (cm) => {
187+
if (this._isSearchOpen()) {
188+
// replace the older search component with the new one
189+
const search = document.querySelector('.CodeMirror-dialog.CodeMirror-dialog-top');
190+
search && search.remove();
191+
}
182192
cm.execCommand('findPersistent');
183193
this._bindSearchHandler();
184194
this._appendSearchResultsCount();
@@ -365,6 +375,10 @@ export default class CodeEditor extends React.Component {
365375
}
366376
};
367377

378+
_isSearchOpen = () => {
379+
return document.querySelector('.CodeMirror-dialog.CodeMirror-dialog-top');
380+
};
381+
368382
/**
369383
* Bind handler to search input to count number of search results
370384
*/

0 commit comments

Comments
 (0)