I am extending the functionality of the lightning-datatable
component and while trying to dispatch a CustomEvent I am receiving the following error:
TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
This is the code I have, you would use lightning-datatable-extended as you normally use the lightning-datatable component.
import LightningDatatable from "lightning/datatable";
export default class LightningDatatableExtended extends LightningDatatable {
boundHandledMouseUp = this.handleMouseUp.bind(this);
constructor() {
super();
this.template.addEventListener("mouseup", this.boundHandledMouseUp);
}
handleMouseUp() {
const myCustomEvent = new CustomEvent("myCustomEvent");
this.dispatchEvent(myCustomEvent);
}
}
UPDATE: I have found this closed issue in github, unfortunately it does not really contain an answer