srigar / multiselect-react-dropdown

React multiselect dropdown with search and various options
https://10xn41w767.codesandbox.io/
MIT License
199 stars 113 forks source link

groupBy not working #179

Closed ahmedgaafer closed 2 years ago

ahmedgaafer commented 2 years ago

When trying to add groupBy options to the component I get the following error

image

the same error shows in the docs

my code


let options = [
            { name: 'Option 1', id: 1, g: 'g1'},
            { name: 'Option 2', id: 2, g: 'g1' },
            { name: 'Option 3', id: 3, g: 'g2' },
            { name: 'Option 4', id: 4, g: 'g2' },
        ];

<Multiselect
  options={this.state.options} // Options to display in the dropdown
  displayValue="name" // Property name to display in the dropdown options
  showCheckbox={true} // Display a checkbox next to each option
  groupBy="g" // Property to group options by
  />
ghost commented 2 years ago

Demo not working either: https://multiselect-react-dropdown.vercel.app/?path=/story/multiselect-dropdown--grouping

ghost commented 2 years ago

Rollback and use multiselect-react-dropdown@2.0.9, it seems to be working from what i can see

EmirSoza commented 2 years ago

(To the developer) : It seems like there is an unknown value (option) is used on renderGroupByOptions function instead of using obj. return Object.keys(groupedObject).map(function (obj) { var isSelected = _this6.isSelectedValue(option); ......

srigar commented 2 years ago

Fix available in v2.0.20