Skip to content
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

Rerender blocks onclick trigger #15334

Closed
olle-forsslof opened this issue Feb 18, 2025 · 5 comments
Closed

Rerender blocks onclick trigger #15334

olle-forsslof opened this issue Feb 18, 2025 · 5 comments

Comments

@olle-forsslof
Copy link

olle-forsslof commented Feb 18, 2025

Describe the bug

I have a button with both onclick and onmousedown. Inside it renders an svg that has an if statement which renders either a circle or a rect.

In the repl, if you check the console, you can se the onclick event only fires every other time. Though if you either remove the if statement or the onmousedown event the onclick fires as it should.

Patrick from the Svelte discord wrote:

It seems like the rerendering has something to do with it.
It might be something in line with this: #15319

Somehow the event is not dispatched if the event.target rerenders. You can see it working correctly when clicking the button in the white area.

Edit: If you add pointer-events: none to the elements inside the svg everything works as expected.

Reproduction

https://svelte.dev/playground/e80c01add66845a1a6f022d12dcd6bda?version=5.20.2

Logs

System Info

Tested on Chrome

Severity

annoyance

@paoloricciuti
Copy link
Member

Mmm this might be browser related...on my phone it triggers everytime

@olle-forsslof
Copy link
Author

Mmm this might be browser related...on my phone it triggers everytime

I don't think it triggers if you press the square or the circle? When pressing the white area in the button it works as it should, as it says in the description.

@paoloricciuti
Copy link
Member

Mmm this might be browser related...on my phone it triggers everytime

I don't think it triggers if you press the square or the circle? When pressing the white area in the button it works as it should, as it says in the description.

Ugh, I should not read issues on the phone while also doing other stuff lol. But I think I might now where to look for this...will see if I can later or tomorrow

@7nik
Copy link
Contributor

7nik commented Feb 19, 2025

I think it is just how the web works: click is sequential mousedown and mouseup on the same element. But on mousedown you change the element to a rect which breaks the sequence. On the next click, the element is already a rect and thus no the sequence breakage.

@paoloricciuti
Copy link
Member

Mmm i think @7nik is right: see this codepen

https://codepen.io/paoloricciuti/pen/ogNbGbd?editors=1111

I'm gonna close this but feel free to open back again if you think this is wrong

@paoloricciuti paoloricciuti closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants