fix(modal): prevent onClose$ from firing on initial mount when show is false#1175
Merged
maiieul merged 3 commits intoqwikifiers:mainfrom Apr 17, 2026
Merged
Conversation
…s false onClose$ should only be called after an open→close transition, not during the initial useTask$ run when the modal starts in a closed state. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
🦋 Changeset detectedLatest commit: aeed3c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Covers the bug where onClose$ was called on initial mount when the modal starts closed. Tests verify callbacks fire only after real open/close transitions and accumulate correctly across multiple cycles. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
commit: |
Merged
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
onClose$was being called on the initialuseTask$run whenever the modal started in a closed state (bind:show = false), because the task unconditionally fell into theelsebranch on first execution.wasOpenSigflag that is set totruethe first time the modal opens.onClose$is now only invoked after a real open → closed transition.onShow$behavior is unchanged.Root cause
In Qwik,
useTask$runs once on mount to register tracking, then re-runs on signal changes. On the first run withshowSig.value === false, the previous code hit theelsebranch and calledonClose$— even though the modal had never been open.