Skip to content

bug: onClick returns MouseEvent Type #6217

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

Open
3 tasks done
pfteter opened this issue Mar 31, 2025 · 0 comments
Open
3 tasks done

bug: onClick returns MouseEvent Type #6217

pfteter opened this issue Mar 31, 2025 · 0 comments
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted

Comments

@pfteter
Copy link

pfteter commented Mar 31, 2025

Prerequisites

Stencil Version

latest

Current Behavior

Stencils onClick event is typed as
(event: MouseEvent) => ...

According to MDN and chrome debugging in modern browsers the on click event / "click" returns a PointerEvent that extends the MouseEvent.

If you inspect the callback of a stencil onClick event you will see that it returns the PointerEvent.
Only support MouseEvent is not wrong it's just if you want to type it correctly TS will complain

Image

see:
Image

Expected Behavior

onClick should be typed to support both PointerEvent and MouseEvent, see:
https://developer.mozilla.org/de/docs/Web/API/Element/click_event

System Info

Steps to Reproduce

const button = document.querySelector("button");

button.addEventListener("click", (event) => {
  button.textContent = `Click count: ${event.detail}`;
});

or JSX
<button onClick="this.eventHandler">

debug in browser dev tools the type is PointerEvent, in Stencil JSX Base only MouseEvent is supported but not PointerEvents.

Code Reproduction URL

http://......

Additional Information

No response

@pfteter pfteter changed the title bug: onClick returns MouseEvent bug: onClick returns MouseEvent Type Mar 31, 2025
@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted
Projects
None yet
Development

No branches or pull requests

2 participants