Business
Jobs
  • About Us
  • Solutions
    • Candidates
      Highly qualified candidates in 48h.
    • Assessments
      500+ technical and psychological assessments, plus anti-fraud system.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Pay in 15+ LATAM countries without setting up a local entity.
  • Pricing
  • Jobs

0

409
Views
Componente MUI TextField con foco y cursor activo

Estoy usando el componente MUI TextField como un formulario de entrada único. Cuando el componente se carga, tiene el foco, pero no el cursor para comenzar a escribir. El usuario aún tiene que hacer clic en la entrada para que aparezca el cursor y comenzar a escribir. Alternativamente, el usuario puede hacer clic en la tecla de tabulación y aparecer el cursor. Pero escribir cualquier otra cosa no activa el cursor ni registra ningún carácter en el TextField. Intenté usar el atributo autoFocus, así como: inputRef={input => input && input.focus()} de esta respuesta .

Aquí está el formulario:

 <FormControl variant="standard" fullWidth> <TextField id="new-comment" label="Comment" multiline minRows={3} maxRows={5} focused={true} value={comment} onChange={updateCommentValue} onKeyDown={keyPress} /> <Button onClick={saveComment}> Comment </Button> </FormControl>

Y aquí hay una imagen del foco sin cursor: TextField con foco pero sin cursor

Y una imagen de enfoque con el cursor después de hacer clic en: TextField con foco y cursor

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes hacerlo de esta manera:

 function MyComponent () { const inputRef = useRef(null); useEffect(() => { inputRef.current.focus() }, []) return ( <TextField inputRef={inputRef} id="new-comment" label="Comment" /> ); }
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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!