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

83
Views
Manually Setting currentTarget with Javascript

I'm consistently having a problem with React / Javascript: often times, I want to anchor something on the close of a modal.

Example

  1. Some modal is triggered, for example, "Would you like to do this or that?", with this and that each being a button.
  2. When the user clicks, this, the modal holding that button closes and causes another DOM element that requires an anchor (in my case, it's a <Popover/> component.

Expected Behavior The popover component is rendered where the this button was clicked, enabling further action from the user.

Observed Behavior The popover component is still rendered, but an error is thrown in the console indicating that the anchor element is undefined.

I know that what's going on here is that the modal with the this and that buttons has now closed, so the Popover has nothing to anchor to. So, I'm wondering if there's an approach that would enable me to close the initial modal with the this and that buttons while still anchoring to the spot where one of the buttons was clicked. That's why I've titled this "manually setting currentTarget", because I'm wondering if there's a way to create this anchor or something like that.

Thanks for your help,

Davis

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!