fix(dockview-core): cancel popout restoration on dispose (#851)#1288
Merged
Conversation
`fromJSON` schedules popout-group restoration via `setTimeout`, but the timer callbacks were not cancelled when the component was disposed and did not check `isDisposed` before calling `addPopoutGroup`. Under React StrictMode the component mounts -> disposes -> remounts, and the first instance's queued restoration still fired against the disposed component, opening a second popout window with a fresh target name. Track each restoration timer in a cleanup set, clear it from the component's main disposable, and early-return from the timeout body if the component is already disposed. The pending promises are resolved during cleanup so callers awaiting `popoutRestorationPromise` don't hang. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
DockviewComponent.fromJSONschedules popout-group restoration viasetTimeout, but the timer callbacks were neither cancelled when the component was disposed nor guarded againstisDisposed. Under StrictMode the component mounts -> disposes -> remounts, and the first instance's queued restoration still fired, opening a second popout window with a fresh sequential target name.Disposable.from(...)block indispose(), and the timeout body early-returns whenthis.isDisposed. Pending promises resolve during cleanup so callers awaitingpopoutRestorationPromisedon't hang.Test plan
dockviewComponent › popout group › issue #851: fromJSON popout restoration is cancelled on dispose— schedules a popout viafromJSON, disposes before the timer fires, runs all fake timers, and assertswindow.openis never called.Received number of calls: 1) and pass with it.popout groupsuite still green (24 tests).🤖 Generated with Claude Code