Skip to content

Commit e9f700c

Browse files
fix: improve popup handling for non-vite environments (#312)
* fix: improve popup handling for non-vite environments * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent e7f2877 commit e9f700c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.changeset/ready-peas-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/devtools': patch
3+
---
4+
5+
fix issue with popups in non-vite environments

packages/devtools/src/context/pip-context.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ export const PiPProvider = (props: PiPProviderProps) => {
5454
'Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.',
5555
)
5656
}
57-
// can be run outside of vite so we ignore the rule
58-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
59-
import.meta?.hot?.on('vite:beforeUpdate', () => {
60-
localStorage.setItem('pip_open', 'false')
61-
closePipWindow()
62-
})
57+
58+
if (import.meta.hot && typeof import.meta.hot.on === 'function') {
59+
import.meta.hot.on('vite:beforeUpdate', () => {
60+
localStorage.setItem('pip_open', 'false')
61+
closePipWindow()
62+
})
63+
}
6364
window.addEventListener('beforeunload', () => {
6465
localStorage.setItem('pip_open', 'false')
6566
closePipWindow()

0 commit comments

Comments
 (0)