Skip to content

Group attributes #5

@reecefenwick

Description

@reecefenwick

Follow example of react-select https://codesandbox.io/s/w6n5llr6kl?module=/example.js

Though there seems to be a bug, I added a "group" to the options prop on FacetedSelect and changed the behaviour of buildOptions() to:

            // sort options by group
            const groupedOptions = new Map();
            for (const o of options) {
                const group = o.group || 'Other';
                const optionsForGroup = groupedOptions.get(group) || [];
                optionsForGroup.push({
                    value: o.label,
                    label: o.label,
                    getSuggestions: o.getSuggestions
                });
                groupedOptions.set(group, optionsForGroup);
            }
            return Array.from(groupedOptions).map(([key, value]) => {
                return {
                    label: key,
                    options: value
                }
            });

Resulting in:

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
at compareOption (Creatable.js:40)
at Creatable.js:51
at Array.some ()
at isValidNewOption (Creatable.js:50)
at Creatable.componentWillReceiveProps (Creatable.js:133)
at callComponentWillReceiveProps (react-dom.development.js:11528)
at updateClassInstance (react-dom.development.js:11720)
at updateClassComponent (react-dom.development.js:13154)
at beginWork (react-dom.development.js:13825)
at performUnitOfWork (react-dom.development.js:15864)

Some related issues:

  1. [V2] Cannot use Createable together with custom getOptionLabel, getCustomValue JedWatson/react-select#2888
  2. [V2] Creatable doesn't use getOptionValue and getOptionLabel props JedWatson/react-select#2630

This feature can be implemented in a non-breaking way so its not urgent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions