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

160
Visualizações
Clear Search value on focus out of a Multiselect - multiselect-react-dropdown (React JS)

I want to clear the search text on focusing out of the multi select field By default onBlur is not provided in the package

By default the search value persists on focus out Search term persisting after focusing out of the field

import { Multiselect } from 'multiselect-react-dropdown';

version: "multiselect-react-dropdown": "^2.0.1"

<Multiselect
options={categoryList} // Options to display in the dropdown
displayValue="name" //Label to be displayed from the object
avoidHighlightFirstOption={true}
// closeIcon="cancel"
emptyRecordMsg={"No Product type available"}
selectedValues={multiSelectedCat && multiSelectedCat.length > 0 ? multiSelectedCat : []} // Preselected value to persist in dropdown
onSelect={multiOnSelectCat} // Function will trigger on select event
onRemove={multiOnRemoveCat} // Function will trigger on remove event />

How can I implement the onBlur functionality as it is not provided by default, and I couldn't find much in docs.

The requirement is to clear the search text on Focus out.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use the ref call back and combine with blur to update inputValue state in Multiselect.

You can see this example: https://codesandbox.io/s/react-playground-forked-kpgmo?file=/index.js

this.multiselectRef = (element) => {
  if (element) {
    $("#search_input").blur(function() {
      setTimeout(function() {
        element.setState({
          inputValue: ""
        });
      }, 1);
    });
  }
};

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