@@ -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 ;
@@ -211,6 +212,11 @@ export class WebViewModel implements ViewModel {
211212 } ) ;
212213 }
213214
215+ dispose ( ) {
216+ this . ctrlShiftUnsubFn ?.( ) ;
217+ this . ctrlShiftUnsubFn = null ;
218+ }
219+
214220 get viewComponent ( ) : ViewComponent {
215221 return WebView ;
216222 }
@@ -508,18 +514,21 @@ export class WebViewModel implements ViewModel {
508514 return true ;
509515 }
510516 const ctrlShiftState = globalStore . get ( getSimpleControlShiftAtom ( ) ) ;
511- if ( ctrlShiftState ) {
517+ if ( ctrlShiftState && ! this . ctrlShiftUnsubFn ) {
512518 // this is really weird, we don't get keyup events from webview
513- const unsubFn = globalStore . sub ( getSimpleControlShiftAtom ( ) , ( ) => {
519+ this . ctrlShiftUnsubFn = globalStore . sub ( getSimpleControlShiftAtom ( ) , ( ) => {
514520 const state = globalStore . get ( getSimpleControlShiftAtom ( ) ) ;
515521 if ( ! state ) {
516- unsubFn ( ) ;
522+ this . ctrlShiftUnsubFn ?.( ) ;
523+ this . ctrlShiftUnsubFn = null ;
517524 const isStillFocused = globalStore . get ( this . nodeModel . isFocused ) ;
518525 if ( isStillFocused ) {
519526 this . webviewRef . current ?. focus ( ) ;
520527 }
521528 }
522529 } ) ;
530+ }
531+ if ( ctrlShiftState ) {
523532 return false ;
524533 }
525534 this . webviewRef . current ?. focus ( ) ;
0 commit comments