Skip to content

bug: onClick returns MouseEvent Type #6217

@pfteter

Description

@pfteter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within StencilHelp Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions