Skip to content

Commit 6113106

Browse files
committed
Send update on tabLostFocus.
1 parent 4e4e5a6 commit 6113106

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/entrypoints/content.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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>'],

src/lib/registries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)