Skip to content

Commit f5bf180

Browse files
authored
fix(query-devtools/PiPContext): reset 'pip_open' in 'localStore' from 'closePipWindow' so the auto-open createEffect does not reopen the window after a programmatic close (#10813)
1 parent 25cdd97 commit f5bf180

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/query-devtools': patch
3+
---
4+
5+
fix(query-devtools/PiPContext): reset 'pip_open' in 'localStore' from 'closePipWindow' so the auto-open createEffect does not reopen the window after a programmatic close

packages/query-devtools/src/__tests__/contexts/PiPContext.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,22 @@ describe('PiPContext', () => {
312312

313313
expect(fakeWindow.close).toHaveBeenCalledTimes(1)
314314
})
315+
316+
it('should reset "pip_open" in "localStore" so the auto-open createEffect does not reopen the window', () => {
317+
stubPipWindow()
318+
319+
renderAndAct(
320+
(pip) => {
321+
pip().requestPipWindow(640, 480)
322+
pip().closePipWindow()
323+
},
324+
{ disabled: true },
325+
)
326+
327+
expect(localStorage.getItem('TanstackQueryDevtools.pip_open')).toBe(
328+
'false',
329+
)
330+
})
315331
})
316332

317333
describe('"pip_open" auto-open createEffect', () => {

packages/query-devtools/src/contexts/PiPContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const PiPProvider = (props: PiPProviderProps) => {
4141
const w = pipWindow()
4242
if (w != null) {
4343
w.close()
44+
props.setLocalStore('pip_open', 'false')
4445
setPipWindow(null)
4546
}
4647
}

0 commit comments

Comments
 (0)