Search code examples
reactjssemantic-uiredux-form

How to restore dropdown to default value in Semantic-UI-React


In default semantic-ui we can do this option: https://github.com/Semantic-Org/Semantic-UI/commit/b4ae26d24f75886c3d5f6fc4f00e176f09705a13 But, how to do it in semantic-ui-react? Google nothing say about it, please, I need help.

What I'm trying to achieve: I'm using redux-form. In my form present semantic component <Form.Select multiple ....> and after success submit - call to redux-form method reset. All is fine, form is clear... but not dropdown/select field. Any ideas?


Solution

  • I solved the problem as follows:

    Semantic-ui-react props value set to the current value of the field.

    <Form.Select
                        name={input.name}
                        options={options}
                        label={label}
                        placeholder={placeholder}
                        search
                        multiple
                        selectOnBlur={selectOnBlur}
                        onFocus={::this.handleFocus}
                        onBlur={::this.handleBlur}
                        onChange={::this.handleChange}
                        defaultValue={defaultValue || []}
                        value={input.value}
                        loading={loading} />