That is indeed a better solution than remembering the last element clicked. Thank you kgscott.
I adapted your solution so a click on the document removes the “active” class on the button. You have to keep event bubbeling in mind though. Without
event.stopPropagation(); both handlers would be fired in sequence, resulting in an immediate removal of the active class (document handler is fired second) just after its addition (button handler is fired first).
However, could this be refered to as best practise? Now every click causes a query for “.dropdown-button.active” within the DOM, right?