Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searchValue is not displayed #161

Open
koalo opened this issue Jul 15, 2019 · 2 comments
Open

searchValue is not displayed #161

koalo opened this issue Jul 15, 2019 · 2 comments

Comments

@koalo
Copy link

koalo commented Jul 15, 2019

Expected Behavior

When I set the property searchValue I would expect that the value appears in the search field and that the items are filtered appropriately.

Actual Behavior

Nothing happens if this property is provided.

Steps to Reproduce the Problem

import React from "react";
import ReactDOM from "react-dom";
import MultiSelect from "@kenshooui/react-multi-select";
import "@kenshooui/react-multi-select/dist/style.css";

import "./styles.css";

function App() {
  const items = [
    { id: 0, label: "item 1" },
    { id: 2, label: "item 2", disabled: true },
    { id: 3, label: "item 3", disabled: false },
    { id: 4, label: "item 4" }
  ];

  return (
    <div className="App">
      <MultiSelect items={items} selectedItems={items} searchValue="1" />
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Also see https://codesandbox.io/embed/react-multi-select-search-test-rsjks

Related

#104

After reading that issue I was expecting that this should work, but I guess I do not understand how to correctly use searchValue.

@yegor-babiy
Copy link
Contributor

@koalo thanks for your feedback,
You should use your own controlled component for it,
as example - https://codesandbox.io/s/intelligent-ganguly-65ic2
I hope it helps you

@jeffwhat
Copy link

jeffwhat commented Mar 12, 2020

I am using a syntax similar to your example code, but it doesn't work:

<MultiSelect 
                  items={this.state.studies} 
                  selectedItems={this.state.selectedStudyList} 
                  onChange={this.handleStudySelect}
                  searchValue={this.state.studiesSearch}
                  searchValueChanged={this.handleStudySearch} 
                  />  

The correct values get set in the state, so the searchValueChanged function works fine, but there doesn't seem to be a way to get the value back into the multiselect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants