Skip to content

Commit

Permalink
fix(popover): add outsideClick event on popover show (#2514)
Browse files Browse the repository at this point in the history
* fix(popover): add outsideClick event on popover show

* docs: create perfect-rockets-approve.md

---------

Co-authored-by: Anuj Singla <[email protected]>
Co-authored-by: Benny Powers <[email protected]>
  • Loading branch information
3 people authored Jun 16, 2023
1 parent 78f3333 commit 2ba0b43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/perfect-rockets-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@patternfly/elements": patch
---

`<pf-popover>`: prevent memory leak by removing event listeners event on popover close
3 changes: 2 additions & 1 deletion elements/pf-popover/pf-popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ export class PfPopover extends LitElement {
connectedCallback() {
super.connectedCallback();
this.addEventListener('keydown', this.onKeydown);
PfPopover.instances.add(this);
}

render() {
Expand Down Expand Up @@ -454,6 +453,7 @@ export class PfPopover extends LitElement {
});
this._popover?.show();
this.dispatchEvent(new PopoverShownEvent());
PfPopover.instances.add(this);
}

/**
Expand All @@ -464,6 +464,7 @@ export class PfPopover extends LitElement {
await this.#float.hide();
this._popover?.close();
this.dispatchEvent(new PopoverHiddenEvent());
PfPopover.instances.delete(this);
}
}

Expand Down

0 comments on commit 2ba0b43

Please sign in to comment.