-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add SelectField #114
Add SelectField #114
Conversation
9cb0912
to
b0d00be
Compare
'errors', | ||
'isVisible', | ||
'renderError', | ||
// data attributes are forwarded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...omit(this.props, Object.keys(SelectField.propTypes)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case doing something like const { hintIcon, badge, ..., ...rest } = this.props
would have been more readable, but against our standards I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty clever! We need to omit additional props as well like hasError
(as we do not want to support it).
I think accepting any props is a bad approach as the API is not clearly defined and prop-spreading is generally hard to deal with.
To me the better approach (compared to what we're currently doing) is to be strict about the props supported in SelectInput
and to remove the prop-forwarding by spread to react-select
there. Then we can also be explicit about the forwarded props here.
I'd do this in a follow-up PR then though (I added it to my list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case doing something like
const { hintIcon, badge, ..., ...rest } = this.props
would have been more readable, but against our standards I suppose.
I like the explicitness of omit
over "abusing" destructuring for omitting purposes, especially as we might need to declare some variables which we then won't use (like hasError
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now created #119 which explicitly declares all props accepted by SelectInput
. I will stop the spread in SelectField
(here) and forward the explicitly as well.
Then we don't need this ugly omission anymore.
56b50ca
to
6d4c168
Compare
6d4c168
to
3b518bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!
static Placeholder = SelectInput.Placeholder; | ||
static SelectContainer = SelectInput.SelectContainer; | ||
static SingleValue = SelectInput.SingleValue; | ||
static ValueContainer = SelectInput.ValueContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
touched: (props, ...rest) => | ||
props.isMulti | ||
? PropTypes.arrayOf(PropTypes.bool, ...rest)(props, ...rest) | ||
: PropTypes.bool(props, ...rest), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 hot damn!
// SelectInput | ||
'aria-label': PropTypes.string, | ||
'aria-labelledby': PropTypes.string, | ||
isAutofocussed: PropTypes.bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh... guess I was the confused one
id: do { | ||
if (props.id) props.id; | ||
else if (state.id) state.id; | ||
else sequentialId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
cd1eda4
to
ac0ddea
Compare
3b518bf
to
44df5ee
Compare
Adds
SelectField
.Needs #119 merged first.