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

150
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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