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

Support value property for multiselect #130

Merged
merged 2 commits into from
Dec 16, 2017
Merged

Support value property for multiselect #130

merged 2 commits into from
Dec 16, 2017

Conversation

tellnobody1
Copy link
Contributor

React warns when using selected for option. They recommend to use value for select.
But when select is multiple it's impossible to pass array of values:

value :: String -> Props

In latest version of React selected for several option won't work.

In JSX/JavaScript it's possible to send value as string and array:

<select value={'A'}>
<select multiple={true} value={['B', 'C']}>

https://reactjs.org/docs/forms.html#the-select-tag

@@ -407,6 +407,9 @@ useMap = unsafeMkProps "useMap"
value :: String -> Props
value = unsafeMkProps "value"

value' :: Array String -> Props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this values or valueArray or something else please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed to valueArray. To keep connection with property name (value).

@paf31
Copy link
Contributor

paf31 commented Nov 30, 2017

Hmm, presumably if we use the wrong one, it'll be a runtime error? That's a shame, but there's not much we can do here without drastically changing the way the API works.

Thanks!

@tellnobody1
Copy link
Contributor Author

<select multiple={false} value={['B', 'C']}>

In this case React will print warning:

Warning: The value prop supplied to must be a scalar value if multiple is false.

@ethul
Copy link
Contributor

ethul commented Dec 16, 2017

Looks good. Thanks for this!

@ethul ethul merged commit 14b4c22 into purescript-contrib:master Dec 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants