mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
Fix BrowserView cleanup on component unmount
- Separate BrowserView cleanup into dedicated useEffect with empty dependency array - Ensures cleanup runs when WebViewer component is unmounted, not just on URL changes - Add detailed logging for debugging BrowserView destruction - Fixes issue where BrowserView persists after closing WebViewer container - Proper cleanup prevents orphaned BrowserView instances floating on screen
This commit is contained in:
@@ -152,15 +152,23 @@ export function WebViewer({
|
||||
}
|
||||
}, 100);
|
||||
|
||||
// Cleanup on unmount
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
if (browserViewCreated && browserViewId.current) {
|
||||
window.electron.destroyBrowserView(browserViewId.current).catch(console.error);
|
||||
}
|
||||
};
|
||||
}, [url]);
|
||||
|
||||
// Cleanup BrowserView on component unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
console.log('WebViewer component unmounting, cleaning up BrowserView:', browserViewId.current);
|
||||
if (browserViewId.current) {
|
||||
window.electron.destroyBrowserView(browserViewId.current).catch((err) => {
|
||||
console.error('Error destroying BrowserView on unmount:', err);
|
||||
});
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Update BrowserView bounds when container resizes
|
||||
useEffect(() => {
|
||||
if (!browserViewCreated || !containerRef.current) return;
|
||||
|
||||
Reference in New Issue
Block a user