Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
How to use onDoubleClick on MUI TextField?

I want to select the text in the input field whenever the user double clicks the input field, I have made a function for this which is,

export const selectText = (
  event: React.MouseEvent<HTMLInputElement | HTMLTextAreaElement, MouseEvent>
): void => {
  event.currentTarget.select();
};

But how to I use it on mui Text Field, there are no props for onDoubleClick in mui documentation. I I simply send a prop

<TextField
  id={id}
  name={name}
  value={value}
  onDoubleClick={selectText}
/>

I get this error,

enter image description here

(I am trying to select numbers on double click not text.)

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can attach it in inputProps to the native input element (that is rendered inside the TextField).

<TextField
    id={id}
    name={name}
    value={value}
    inputProps={{
        onDoubleClick: selectText
    }}
/>
about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want to know when the user double click:

<TextField onDoubleClick={() => console.log('double click')} />

If you only want double click without having to listen to the single click event:

<TextField onClick={(e) => e.detail === 2 && console.log('double click only')} />

Live Demo

Codesandbox Demo

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda