Skip to content

Commit

Permalink
Fix any previous selections
Browse files Browse the repository at this point in the history
  • Loading branch information
Drarig29 committed Jul 9, 2023
1 parent c62f230 commit 49e13b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/brackets-viewer.min.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class BracketsViewer {
this.popover.setAttribute('popover', 'auto');
this.popover.addEventListener('toggle', (event) => {
if ((event as ToggleEvent).newState === 'closed')
document.querySelector('.opponents.popover-selected')?.classList.remove('popover-selected');
this.clearPreviousPopoverSelections();
});

root.append(this.popover);
Expand Down Expand Up @@ -638,6 +638,7 @@ export class BracketsViewer {
this._onMatchLabelClick(match);

if (this.config.showPopoverOnMatchLabelClick) {
this.clearPreviousPopoverSelections();
opponents.classList.add('popover-selected');
this.showPopover(match);
}
Expand Down Expand Up @@ -760,4 +761,11 @@ export class BracketsViewer {

setupListeners(refs);
}

/**
* Clears any previous popover selections.
*/
private clearPreviousPopoverSelections(): void {
document.querySelector('.opponents.popover-selected')?.classList.remove('popover-selected');
}
}

0 comments on commit 49e13b4

Please sign in to comment.