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

158
Visualizações
How to find x and y coordinates of a button while using keyboard navigation?

I am showing a dropdown which is rendered on click of an icon. The same dropdown is also rendered on right click of another div as well. It takes x and y coordinates of the mouse click event to render the dropdown at the right position. This is the icon's code:

<Icon onClick={this.handleOnClick} onKeyDown={this.handleOnClick}/>

When I do keyboard navigation and press Enter on the icon, the render function for dropdown is called, but since the event doesn't have an X and Y coordinate so the dropdown is rendered on the top left of the page at (0, 0).

Is there a way I can somehow get the position of the button when I am doing keyboard navigation?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I got this working using :

document.activeElement.getBoundingClientRect();

On Key event, I invoked this method.This method gives an object which contains x and y coordinates along with the height, width and other such properties

about 4 years ago · Juan Pablo Isaza Relatório
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