Skip to content

Commit

Permalink
Don't loose focus after clicking toolbar buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmalloy committed Sep 14, 2024
1 parent 4c779e8 commit 507f6fc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/form/editor/editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {
}
}
if ('vibrate' in navigator) navigator.vibrate([2, 8, 8]);
this.editor?.nativeElement.focus();
}

setResponse(tag: string) {
Expand All @@ -229,6 +230,7 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {
this.syncTags.next(this.tags = [...without(this.tags!, ...this.responseButtons.map(p => p.tag)), tag]);
}
if ('vibrate' in navigator) navigator.vibrate([2, 8, 8]);
this.editor?.nativeElement.focus();
}

setText = throttle((value: string) => {
Expand Down Expand Up @@ -256,6 +258,7 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {

togglePreview() {
this.store.local.showPreview = this.preview = !this.preview;
this.editor?.nativeElement.focus();
}

toggleStacked() {
Expand All @@ -269,6 +272,7 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {
} else {
this.store.local.editorStacked = this.stacked = true;
}
this.editor?.nativeElement.focus();
}

toggleFullscreen(override?: boolean) {
Expand All @@ -293,6 +297,7 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {
this.overlayRef.backdropClick().subscribe(() => this.toggleFullscreen(false));
this.overlayRef.keydownEvents().subscribe(event => event.key === "Escape" && this.toggleFullscreen(false));
this.editor?.nativeElement.focus();
defer(() => this.editor?.nativeElement.scrollIntoView(true));
} else {
this.stacked = true;
this.preview = this.store.local.showPreview;
Expand All @@ -301,6 +306,7 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {
delete this.overlayRef;
document.body.style.height = '';
}
this.editor?.nativeElement.focus();
}

toggleHelp(override?: boolean) {
Expand Down Expand Up @@ -343,5 +349,6 @@ export class EditorComponent implements OnChanges, AfterViewInit, OnDestroy {
} {
this.store.eventBus.fire(event);
}
this.editor?.nativeElement.focus();
}
}

0 comments on commit 507f6fc

Please sign in to comment.