Skip to content

Commit 5d9bebb

Browse files
committed
fix: focus redirection on attach and show
1 parent b7c9d92 commit 5d9bebb

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/service/FrameService.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ class FrameService {
324324

325325
public show(): void {
326326
this.getFrame()!.show();
327-
ViewService.focus();
328327
}
329328

330329
public hide(): void {

src/service/ViewService.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import AppState from '@/AppState';
22
import { Settings } from '@/data/Constants';
33
import Storage from '@/data/Storage';
44
import { PageView } from '@/model/Page';
5+
import FramePropagator from '@/propagator/FramePropagator';
56
import ViewPropagator from '@/propagator/ViewPropagator';
67
import FrameService from '@/service/FrameService';
78
import MenuService, { ContextMenuType } from '@/service/MenuService';
@@ -18,6 +19,17 @@ export type ChildWebContents = WebContents & { __parent__?: WebContents };
1819

1920
class ViewService {
2021
private lastContextMenuLinkUrl = '';
22+
23+
constructor() {
24+
this.registerEvents();
25+
}
26+
27+
private registerEvents(): void {
28+
const redirectFocus = () => this.focus();
29+
FramePropagator.on('show', redirectFocus);
30+
ViewPropagator.on('attached', redirectFocus);
31+
}
32+
2133
public getHomeUrl(WebContentsView: WebContentsView): string {
2234
return WebContentsView.webContents.getURL();
2335
}
@@ -68,7 +80,7 @@ class ViewService {
6880
return view.webContents.isLoading();
6981
}
7082

71-
public focus(view = this.getCurrentView()): void {
83+
private focus(view = this.getCurrentView()): void {
7284
if (!view) { console.error('Cannot focus without view.'); return; }
7385
const wc = view.webContents;
7486
if (!wc || wc.isDestroyed()) { console.error('Cannot focus with destroyed view.'); return; }

0 commit comments

Comments
 (0)