From 31feb46ebc579ea47a565fb021dc083dd21fc354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Kiss?= Date: Sat, 1 Jun 2024 14:17:47 +0200 Subject: [PATCH] fix: macro command editor and url line number sync (#2295) --- .../tab/command/macro-command-editor.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts index c47fa214bd3..46653e5f145 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/command/macro-command-editor.component.ts @@ -87,6 +87,7 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA editor: MonacoStandaloneCodeEditor; containerHeight = '54px'; + private actionIndexQueryParam: string | undefined; private columnNr = 1; private lineHeight = 18; private lineNr = 1; @@ -143,6 +144,7 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA ); // read column and line numbers directly for performance reason. this.subscriptions.add(this.route.queryParams.subscribe(params => { + this.actionIndexQueryParam = params.actionIndex; const columnNr = +params.columnNr; if (!Number.isNaN(columnNr)) { this.columnNr = columnNr; @@ -247,6 +249,11 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA debounceTime(MACRO_CHANGE_DEBOUNCE_TIME), distinctUntilChanged(isEqual) ).subscribe(data => { + // there is a debounce so maybe the editor will list the focus + if (!this.isFocused) { + return; + } + this.router.navigate([], { queryParams: { columnNr: data.columnNr, @@ -446,7 +453,8 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA }); } - if (!this.isFocused) { + // use coercing because the query parameter is string + if (!this.isFocused && this.actionIndexQueryParam && this.actionIndexQueryParam == this.index) { this.editor.focus(); } });