Hey all,
I’ve built a custom element that’s a simple button component. I’ve made it containerless to not break styles/make markup more readable. The component dispatches a custom click event back to the parent to call its custom click.delegate function. This breaks for two uses of the button when it is the ‘save’ action in a dialog and I can’t figure out why. Changing to .trigger works but I dont see why I should have to use .trigger
//button-component. js
constructor(element) {
this.element = element;
}
onClick() {
this.element.dispatchEvent(new CustomEvent('click', { bubbles: true }));
}
//button-component.html
<template>
<button click.delegate="onClick()"></button>
</template>
//usage in mark up
<button-component click.delegate="save()">
Save
</button-component>