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

256
Views
Prevent mat-menu close on form input focus

I have a feedback form inside a mat-menu that looks like this:

<mat-menu #menu="matMenu" xPosition="before" class="filter-menu" (click)="$event.stopPropagation();">
      <div>
          <form [formGroup]="feedbackForm" (submit)="submitFeedback()">
              <div class="form__wrapper mt-4">
                  <div class="flex">
                         <div>
                            <label for="email" class="form__label">Email</label>
                             <input type="email" name="email" disabled 
placeholder="{{email}}" id="">
                          </div>
                  </div>
                  <div>
                       <label for="feedback" class="form__label">Feedback</label>
                         <textarea placeholder="Your feedback" formControlName="feedback" rows="4" name="feedback"></textarea>
                  </div>
                    <button class="btn" type="submit">Send Message</button>
               </div>
           </form>
    </div>
</mat-menu>

I added $event.stopPropagation(); to prevent the menu from closing when I click inside it but it still closes when I focus on the textarea. Any help on what could be causing this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your event.stopPropagation() needs to be in the function triggered by the focus event on the input field being focused on.

You need to pass the event when the (focus)="myFunc($event) and then in the myFunc(event) { event.stopPropagation() }.

This should work :)

about 4 years ago · Juan Pablo Isaza Report
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!