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

Form.Select - placeholder disappearing #1983

Closed
rafalradomski opened this issue Aug 20, 2017 · 5 comments
Closed

Form.Select - placeholder disappearing #1983

rafalradomski opened this issue Aug 20, 2017 · 5 comments
Labels

Comments

@rafalradomski
Copy link

rafalradomski commented Aug 20, 2017

I want select list where I can select null value

When I choose item from the list, placeholder disappearing

                    <Form.Select
                        name="parentId"
                        value={this.state.parentId}
                        options={options}
                        onChange={this.handleChange.bind(this)}
                        placeholder='Parent Id'
                    />

When I trying add extra item with empty value, it's not set as default.

            options.push({
                'key': '1',
                'text': 'Parent Id',
                'value': ''
            })

How to make placeholder presist or set empty value as default?

Version

0.71.1

@levithomason
Copy link
Member

Hm, could you provide an example of the component with the props you want and the example rendered output you are expecting? I'm not quite sure I understand.

@rafalradomski
Copy link
Author

rafalradomski commented Aug 22, 2017

Hi @levithomason I looking for something like this: https://jsfiddle.net/xu4fv5n0/2/ where I can cancel current value, and I can see again default value = Placeholder = null

I don't know why when you choose one option, there is no way back...

@layershifter
Copy link
Member

You should use controlled components, I've made a codepen that shows how to do this. SO is better place for questions.

@rafalradomski
Copy link
Author

rafalradomski commented Aug 25, 2017

@layershifter thx, but your example doesn't work, when you select option, reset and try select again it doesn't work

By the way, why I need separate button to clear select? it's bad UI, normal select can handle both cases

If you preventing applying null value, you should provide some solution to easily reset select list with out some extra UI elements...

@layershifter
Copy link
Member

but your example doesn't work

Yep, I've forgot to add onChange handler.

By the way, why I need separate button to clear select?

How you want to reset value in another way? 🙃 Something should change the state.

I've copied behaviour to icon on Dropdown, so it resets value as in your example. However, it needs more styling and more logic because it's not a SUI feature. See codepen.

If you preventing applying null value

handleReset sets value to null. '' don't accepted as value, there is already issue about this #1748.
placeholder behaviour is also was discussed there #1299. Contributions are welcome.

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

No branches or pull requests

3 participants