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

112
Views
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 answers
Answer question

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 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!