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

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

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