File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ export default defineContentScript({
40
40
childList : true ,
41
41
subtree : true ,
42
42
} )
43
+
44
+ // Listen for tab visibility changes to capture draft content when switching tabs
45
+ document . addEventListener ( 'visibilitychange' , ( ) => {
46
+ if ( document . hidden ) {
47
+ enhancedTextareas . tabLostFocus ( )
48
+ }
49
+ } )
50
+
43
51
logger . debug ( 'Extension loaded with' , enhancers . getEnhancerCount ( ) , 'handlers' )
44
52
} ,
45
53
matches : [ '<all_urls>' ] ,
Original file line number Diff line number Diff line change @@ -140,4 +140,10 @@ export class TextareaRegistry {
140
140
get ( textarea : HTMLTextAreaElement ) : EnhancedTextarea | undefined {
141
141
return this . textareas . get ( textarea )
142
142
}
143
+
144
+ tabLostFocus ( ) : void {
145
+ for ( const enhanced of this . textareas . values ( ) ) {
146
+ this . sendEvent ( 'LOST_FOCUS' , enhanced )
147
+ }
148
+ }
143
149
}
You can’t perform that action at this time.
0 commit comments