Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

461
Views
Boostrap 5 Accordion not collpasing

I am using Bootstrap accordion in my stenciljs app as follows:

    <div class="ba-accordion">
        <div class="accordion-item">
          <div class="accordion-header" id="kpf-accordion-nachrichtenverlauf-heading">
            <button class="accordion-button" id="accordion-button"
                    type="button"
                    data-bs-toggle="collapse"
                    data-bs-target="#kpf-accordion-nachrichtenverlauf-panel"
                    aria-expanded="false"
                    aria-controls="kpf-accordion-nachrichtenverlauf-panel" onClick={()=>{this._nachrichtenVerlaufPanelClickHandler()}}
                    >
              <p class="kpf-nachrichtenverlauf">Message History</p>
            </button>
          </div>
          <div id="kpf-accordion-nachrichtenverlauf-panel"
               class="accordion-collapse collapse"
               aria-labelledby="kpf-accordion-nachrichtenverlauf-heading"
               >
            <div class="accordion-body">
                
            </div>
          </div>
        </div>
      </div>

It works properly when I test locally with npm start but when I run the app on nginx Server, then it opens once and does not close. On analyzing the elements in browser, I see that the panel item div with id="kpf-accordion-nachrichtenverlauf-panel" always has the class show and if direcly remove it in browser, it closes but if I do this progrmmatically, nothing happens and the accordion remains open. Following is the Javascript click handler code:

  private _nachrichtenVerlaufPanelClickHandler() {

    var nachrichtenVerlaufHeading = document.getElementById('accordion-button');
    var panel = document.getElementById('kpf-accordion-nachrichtenverlauf-panel')



    if(nachrichtenVerlaufHeading.getAttribute('aria-expanded') === "true") {
      console.log("INSIDE THE IF");
       panel.classList.remove('show');
  }
}

The behaviour is the same in Edge and Chrome. How can I fix this thing?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!