Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions frontend/app/view/webview/webview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class WebViewModel implements ViewModel {
partitionOverride: PrimitiveAtom<string> | null;
userAgentType: Atom<string>;
env: WebViewEnv;
ctrlShiftUnsubFn: (() => void) | null = null;

constructor({ blockId, nodeModel, tabModel, waveEnv }: ViewModelInitType) {
this.nodeModel = nodeModel;
Expand Down Expand Up @@ -211,6 +212,11 @@ export class WebViewModel implements ViewModel {
});
}

dispose() {
this.ctrlShiftUnsubFn?.();
this.ctrlShiftUnsubFn = null;
}

get viewComponent(): ViewComponent {
return WebView;
}
Expand Down Expand Up @@ -508,18 +514,21 @@ export class WebViewModel implements ViewModel {
return true;
}
const ctrlShiftState = globalStore.get(getSimpleControlShiftAtom());
if (ctrlShiftState) {
if (ctrlShiftState && !this.ctrlShiftUnsubFn) {
// this is really weird, we don't get keyup events from webview
const unsubFn = globalStore.sub(getSimpleControlShiftAtom(), () => {
this.ctrlShiftUnsubFn = globalStore.sub(getSimpleControlShiftAtom(), () => {
const state = globalStore.get(getSimpleControlShiftAtom());
if (!state) {
unsubFn();
this.ctrlShiftUnsubFn?.();
this.ctrlShiftUnsubFn = null;
const isStillFocused = globalStore.get(this.nodeModel.isFocused);
if (isStillFocused) {
this.webviewRef.current?.focus();
}
}
});
}
if (ctrlShiftState) {
return false;
}
this.webviewRef.current?.focus();
Expand Down
Loading