Avoid null dereference when removing event listeners in Dropdown (#958)

This commit is contained in:
bolte-17
2022-10-27 09:28:35 -04:00
committed by GitHub
parent a8de02bd53
commit 8893045bf1

View File

@@ -346,8 +346,10 @@ export default class SlDropdown extends ShoelaceElement {
}
removeOpenListeners() {
this.panel.removeEventListener('sl-activate', this.handleMenuItemActivate);
this.panel.removeEventListener('sl-select', this.handlePanelSelect);
if (this.panel) {
this.panel.removeEventListener('sl-activate', this.handleMenuItemActivate);
this.panel.removeEventListener('sl-select', this.handlePanelSelect);
}
document.removeEventListener('keydown', this.handleDocumentKeyDown);
document.removeEventListener('mousedown', this.handleDocumentMouseDown);
}