-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐞] Event handlers either disappearing or included twice depending on the component JSX #4464
Labels
Comments
jwickers
added
TYPE: bug
Something isn't working
STATUS-1: needs triage
New issue which needs to be triaged
labels
Jun 12, 2023
Start a new pull request in StackBlitz Codeflow. |
Thanks a lot @jwickers and sorry for the delay If this isn't fixed by now, it'll definitely be easier to solve in V2 I believe We'll add a test for it in the V2 branch to verify this is not repeating |
shairez
added
VERSION: upcoming major
STATUS-2: team is working on this
Scheduled for work by the core team
and removed
STATUS-1: needs triage
New issue which needs to be triaged
labels
May 25, 2024
maiieul
removed
STATUS-2: team is working on this
Scheduled for work by the core team
P2: minor
labels
Aug 17, 2024
I'm closing this since it's fixed in v2. We're hoping to get the alpha out soon. |
github-project-automation
bot
moved this from Waiting For Review
to Done
in Qwik Development
Nov 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which component is affected?
Qwik Runtime
Describe the bug
There is a weird interaction between component event handlers like
useOn
,useOnDocument
oruseOnWindow
and the JSX structure.Reproduction
You can see this stackblitz as well: https://stackblitz.com/edit/qwik-starter-mkqcen?file=src%2Froutes%2Findex.tsx
Press any key on the page to start and see both components render the events counts.
Press the escape key to switch the component render which changes the behavior.
BUG 1
When the component renders fragment, Qwik places a
<script type="placeholder"
tag with the Qwik event handlers (likeon-document:xxx
). If the component changes to render a DIV for example, that placeholder is removed and the DIV now has the event handlers. So far so good.But if the component renders back to a fragment then the DIV is not replaced back with a placeholder tag thus losing the event handlers altogether.
BUG 2
An easy workaround seems to be to avoid using a fragment as root in the JSX and say wrap the whole component in a DIV.
But when the component changes to render an inner DIV, that inner DIV then also gets the event handlers, causing those events to be processed twice.
Reproduction
https://github.com/jwickers/qwik-useon-events-bug
Steps to reproduce
Run
npm install
andnpm run start
.System Info
Additional Information
No response
The text was updated successfully, but these errors were encountered: