Restore breakpoint editor background, fix enter keybindings
[email protected]
Bug: 1260313
Change-Id: I6a10d4030c92c0e884a67e97f91b08fed11ae843
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3226465
Reviewed-by: Alex Rudenko <[email protected]>
Commit-Queue: Alex Rudenko <[email protected]>
diff --git a/front_end/panels/sources/BreakpointEditDialog.ts b/front_end/panels/sources/BreakpointEditDialog.ts
index 3808912..28db993 100644
--- a/front_end/panels/sources/BreakpointEditDialog.ts
+++ b/front_end/panels/sources/BreakpointEditDialog.ts
@@ -117,16 +117,25 @@
toolbar.appendToolbarItem(this.typeSelector);
const content = oldCondition || '';
+ const finishIfComplete = (view: CodeMirror.EditorView): boolean => {
+ if (modTextEditor.JavaScript.isExpressionComplete(view.state)) {
+ this.finishEditing(true, this.editor.state.doc.toString());
+ return true;
+ }
+ return false;
+ };
const keymap = [
{
key: 'Mod-Enter',
- run: (view: CodeMirror.EditorView): boolean => {
- if (modTextEditor.JavaScript.isExpressionComplete(view.state)) {
- this.finishEditing(true, this.editor.state.doc.toString());
- return true;
- }
- return false;
- },
+ run: finishIfComplete,
+ },
+ {
+ key: 'Enter',
+ run: finishIfComplete,
+ },
+ {
+ ...modCodeMirror.standardKeymap.find(binding => binding.key === 'Enter') as CodeMirror.KeyBinding,
+ key: 'Shift-Enter',
},
{
key: 'Escape',
@@ -139,6 +148,9 @@
this.placeholderCompartment = new modCodeMirror.Compartment();
+ const editorWrapper = this.contentElement.appendChild(document.createElement('div'));
+ editorWrapper.classList.add('condition-editor');
+
this.editor = new modTextEditor.TextEditor.TextEditor(modCodeMirror.EditorState.create({
doc: content,
selection: {anchor: 0, head: content.length},
@@ -148,10 +160,10 @@
editorConfig,
],
}));
- this.editor.classList.add('condition-editor');
+ editorWrapper.appendChild(this.editor);
this.updateTooltip();
- this.contentElement.appendChild(this.editor);
+
this.element.addEventListener('blur', event => {
if (!event.relatedTarget ||
(event.relatedTarget && !(event.relatedTarget as Node).isSelfOrDescendant(this.element))) {