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

119
Visualizações
How can I focus the cursor to the next TextInput in a React Draggable Menu?

I have a draggable context menu with three rows and three TextInputs. Right now I have two bugs:

  1. When "tab" is hit, the menu closes
  2. Even when I stop "tab" from closing (I return in the handleClose), "tab" doesn't focus the cursor to the next TextInput.

I've tried adding tabIndex={0} to the three divs that surround each TextInput, but this didn't help with the tab issue.

Does anyone know what might be wrong here?

Below is the simplified code (variables such as startNumber, endNumber, comments are state variables).

const handleClose = (event?, reason?) => {
  if (reason && reason === 'tabKeyDown') {
    // Prevent the 'Tab' key from closing the window
    return;
  }
  setShouldOpen(false);
  otherStuffHere();
}

...

return (
<Draggable cancel="textarea">
<Menu
  open={shouldOpen}
  onClose={handleClose}
  anchorReference="anchorPosition"
  anchorPosition={{ top: y, left: x }}
  className={classes.myContextMenu}
>

  <div className={classes.row}>
    <div className={classes.title}>
      <Text>First number</Text>
    </div>
    <div className={classes.text} tabIndex={0}>
      <TextInput
        fullWidth
        value={startNumber}
        disabled={readOnly}
        onChange={handleStartNumberChange}
      />
    </div>
  </div>

  <div className={classes.row}>
    <div className={classes.title}>
      <Text>End number</Text>
    </div>
    <div className={classes.text} tabIndex={0}>
      <TextInput
        fullWidth
        value={endNumber}
        disabled={readOnly}
        onChange={handleEndNumberChange}
      />
    </div>
  </div>

  <div className={classes.row}>
    <div className={classes.title}>
      <Text>Comments</Text>
    </div>
    <div className={classes.text} tabIndex={0}>
      <TextInput
        fullWidth
        value={comments}
        disabled={readOnly}
        onChange={handleCommentsChange}
      />
    </div>
  </div>
</Menu>
</Draggable>
)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I wasn't able to find a solution while still using the Menu component, but I used the Popover component instead.

Using the same CSS and same everything else, I got the tab to work as intended without changing the UI.

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