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({
4040 childList : true ,
4141 subtree : true ,
4242 } )
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+
4351 logger . debug ( 'Extension loaded with' , enhancers . getEnhancerCount ( ) , 'handlers' )
4452 } ,
4553 matches : [ '<all_urls>' ] ,
Original file line number Diff line number Diff line change @@ -140,4 +140,10 @@ export class TextareaRegistry {
140140 get ( textarea : HTMLTextAreaElement ) : EnhancedTextarea | undefined {
141141 return this . textareas . get ( textarea )
142142 }
143+
144+ tabLostFocus ( ) : void {
145+ for ( const enhanced of this . textareas . values ( ) ) {
146+ this . sendEvent ( 'LOST_FOCUS' , enhanced )
147+ }
148+ }
143149}
You can’t perform that action at this time.
0 commit comments