Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

88
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda