Skip to content

Commit 697b959

Browse files
committed
minor, fix double sub in webview giveFocus
1 parent 645424a commit 697b959

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

frontend/app/view/webview/webview.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class WebViewModel implements ViewModel {
7474
partitionOverride: PrimitiveAtom<string> | null;
7575
userAgentType: Atom<string>;
7676
env: WebViewEnv;
77+
ctrlShiftUnsubFn: (() => void) | null = null;
7778

7879
constructor({ blockId, nodeModel, tabModel, waveEnv }: ViewModelInitType) {
7980
this.nodeModel = nodeModel;
@@ -508,18 +509,21 @@ export class WebViewModel implements ViewModel {
508509
return true;
509510
}
510511
const ctrlShiftState = globalStore.get(getSimpleControlShiftAtom());
511-
if (ctrlShiftState) {
512+
if (ctrlShiftState && !this.ctrlShiftUnsubFn) {
512513
// this is really weird, we don't get keyup events from webview
513-
const unsubFn = globalStore.sub(getSimpleControlShiftAtom(), () => {
514+
this.ctrlShiftUnsubFn = globalStore.sub(getSimpleControlShiftAtom(), () => {
514515
const state = globalStore.get(getSimpleControlShiftAtom());
515516
if (!state) {
516-
unsubFn();
517+
this.ctrlShiftUnsubFn?.();
518+
this.ctrlShiftUnsubFn = null;
517519
const isStillFocused = globalStore.get(this.nodeModel.isFocused);
518520
if (isStillFocused) {
519521
this.webviewRef.current?.focus();
520522
}
521523
}
522524
});
525+
}
526+
if (ctrlShiftState) {
523527
return false;
524528
}
525529
this.webviewRef.current?.focus();

0 commit comments

Comments
 (0)