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

Couldn't stop click event of a disabled button from bubbling #681

Closed
mgenware opened this issue May 23, 2019 · 3 comments
Closed

Couldn't stop click event of a disabled button from bubbling #681

mgenware opened this issue May 23, 2019 · 3 comments

Comments

@mgenware
Copy link

mgenware commented May 23, 2019

Description

Three disabled buttons shown in the demo page.

button0 is plain HTML/JS, no click handler triggered after click
button1 is a lit-element, handler triggered after click, seems click event is bubbling.
button2 is a lit-element, i called e.stopPropagation in the inner handler, still cannot stop it from bubbling.

Live Demo

https://stackblitz.com/edit/hy4yqu

Steps to Reproduce

Click button1 and button2

Expected Results

No alert

Actual Results

Alert shown

Browsers Affected

  • Chrome
  • Safari 11

Versions

  • lit-element: v2.1.0
  • webcomponents: v2.2.10
@Westbrook
Copy link
Contributor

@mgenware in the case of my-button-v2.ts you are getting very close to what will be needed here, however to stop propagation to listeners on the same element you need to use stopImmediatePropagation() a la https://stackblitz.com/edit/hy4yqu-d6jkx9?file=my-button-v2.ts

Here's the MDN docs on that API https://developer.mozilla.org/en-US/docs/Web/API/Event/stopImmediatePropagation

Good luck!

@mgenware
Copy link
Author

Wow it works! thanks @Westbrook

@kevinpschaaf
Copy link
Member

Sounds like there's not a LitElement bug here. Closing; please re-open if there is anything outstanding.

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