title: How to toggle the class
body: <p>Hi folks i am having problem to execute this code in the browser onclick event on an icon when i click it it works fine when i click to close the list it close and open again like on the mouse down it close and then releasing the button it open again here is the function code where i am doing wrong</p>
  
  <pre><code>toggleExpand(e, focus = true) {
     this.moving = true;
     if (e) {
        e.preventDefault();
        e.stopPropagation();
     }
     this.expanded = !this.expanded;
     toggleClass(this.config.open, this.el);
     ariaToggle('opened', this.current);
     if (!this.selected) {
        toggleClass(this.config.icons.expanded, this.icon);
     }
  
     if (this.expanded) {
        this.select();
        console.log('Clicked1');
  
        if (this.params.scrollToView) {
           this.el.parentElement.previousElementSibling.scrollIntoView();
        }
     } else {
        this.current.setAttribute('tabindex', 0);
        console.log('Clicked2');
        if (focus) {
           this.current.focus();
        }
     }
     setTimeout(() =&gt; {
        this.moving = false;
     }, 100);
  }
  </code></pre>
  
  <p>i put the console to check it on 1st click i get clicked1 on on 2nd i get clicked2 and instantly clicked1 again how to stop it here without css.</p>