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

Capture events not working in JSX #2889

Closed
kensodemann opened this issue Apr 20, 2021 · 3 comments
Closed

Capture events not working in JSX #2889

kensodemann opened this issue Apr 20, 2021 · 3 comments
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@kensodemann
Copy link
Contributor

Stencil version:

 @stencil/core@2.5.2

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
The following talks about a specific event, but the same applies to other events as well.

When onKeyDownCapture is bound on an HTML element in the JSX, it is never fired. For example:

<input onKeyDown={() => console.log('JSX: onKeyDown')}
            onKeyDownCapture={() => console.log('JSX: onKeyDownCapture')} />;

When the component containing this is rendered and the user types in the input, only the "JSX: onKeyDown" is output to the console.

Placing this same input markup inside a React component will result in first the "JSX: onKeyDownCapture" and then the "JSX: onKeyDown" message being logged to the console.

It should be noted that adding a method to the component with a @Listen('keydown', { capture: true }) does work as expected. It is only the bindings on elements within the JSX that is not working as expected.

Expected behavior:
Capture events bound on the HTML elements should fire as expected during the capture phase of the event.

Steps to reproduce:

Related code:

Key portion of demo: https://github.com/jcfranco/stencil-vdom-capture-listeners-not-firing/blob/master/src/components/my-component/my-component.tsx

@tanner-reits
Copy link
Contributor

This was fixed in #4968 and released in Stencil v4.7.0

@nwhittaker
Copy link

Can this issue be reopened? When using onKeyDownCapture, I see an event listener is created on the element listening for keyDown event types. However, it never hits because the actual event type should be keydown (all lower case).

The linked PR only tests click capture events, so it's unclear if this is a regression or if this issue was never really resolved.

@christian-bromann
Copy link
Member

@nwhittaker mind raising a new issue with a reproducible example? Thank you!

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
Projects
None yet
Development

No branches or pull requests

6 participants