Skip to content

Commit

Permalink
chore(components): close megadropdown onfocusout of the post-header
Browse files Browse the repository at this point in the history
  • Loading branch information
myrta2302 committed Dec 17, 2024
1 parent 95f7983 commit 56da030
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export class PostMegadropdown {
this.popoverRef.hide();
}

private handleFocusout(event: FocusEvent) {
const relatedTarget = event.relatedTarget as HTMLElement;
const megaDd = this.popoverRef.querySelector('.megadropdown');
if (!megaDd.contains(relatedTarget)) {
this.hide();
}
}

render() {
return (
<Host>
Expand All @@ -89,7 +97,7 @@ export class PostMegadropdown {
edge-gap="0"
ref={el => (this.popoverRef = el)}
>
<div class="megadropdown">
<div class="megadropdown" onFocusout={e => this.handleFocusout(e)}>
<div onClick={() => this.handleBackButtonClick()} class="back-button">
<slot name="back-button"></slot>
</div>
Expand Down

0 comments on commit 56da030

Please sign in to comment.