furqanZafar / react-selectize

http://furqanzafar.github.io/react-selectize/
Apache License 2.0
704 stars 138 forks source link

Add option to customize "Add {label}..." string #133

Open stizzlestizzle opened 7 years ago

stizzlestizzle commented 7 years ago

Thanks for this plugin!

Currently, if createFromSearch is enabled and a new option is being entered by the user, the string Add {label}... is displayed. This string is hard-coded and the only way to override it is to provide a custom renderOption which seems overkill to me.

It would be nice to have an option to simply specify the desired string.

gabrielrosas commented 7 years ago
<SimpleSelect
    ...
    renderOption={(arg) =>{
        var label, newOption, selectable, isSelectable;
        if (arg != null) {
            label = arg.label, newOption = arg.newOption, selectable = arg.selectable;
        }
        isSelectable = typeof selectable === 'undefined' || selectable;
        return (
            <div className={"simple-option " + (isSelectable ? '' : 'not-selectable')}>
                <span>{!!newOption ? "CUSTOM_LABEL" + label + "..." : label}</span>
            </div>
        )
    }}
/>