-
Notifications
You must be signed in to change notification settings - Fork 255
Conversation
Thanks @joshq00! I really appreciate the help to make I understand we could do a cleanup in the |
I don't see any problem with keeping them in the However, I don't think they should be required if they are not required on the native input element. For example, if I want a text box without a label (maybe I'm just using <Textfield label="" /> Without doing label="", I don't just get an invariant warning... I actually get an error thrown |
I think it really depends. Because you know how the component is built, you know you can use a lot of props that are not described. But ideally, props should describe what you can use (or at least those who are supported and tested). A slider without the min/max value for example doesn't make a lot of sense, but because it's an input behind the scene, you know you can provide them. In the implementation of a MDL Textfield, the label is required (for the bottom border when it's focused). So that's the reason why it's needed. |
I made a fiddle testing behavior with/without labels Everything appears to be working properly without labels |
Yes the input still works. But it doesn't have the MDL styles. Label is required with a MDL Textfield, we cannot change that. |
Fair enough. Anyhow, I didn't remove |
For now, because there's no documentation, I prefer keeping the propTypes because they are kind of a documentation as well. Could you rebase instead of merge? To avoid having these merge commits ? :) |
Rebased |
Could you please only change the way the event is sent inside |
I'll get those back in today or tomorrow at latest |
Fixes tleunen#82 There are still some components where value, id, name are handled manually.
@tleunen should be all ready now |
@@ -12,7 +12,7 @@ class RadioGroup extends React.Component { | |||
}), | |||
container: PropTypes.string, | |||
name: PropTypes.string.isRequired, | |||
onChange: PropTypes.func.isRequired, | |||
onChange: PropTypes.func, |
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.
any reason why it's not required anymore?
Usually, React wants us to provide an onChange
callback if we set a value
.
This is valable for every input.
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.
Exactly my reasoning. React already handles the checking and it's not required on the true input element. Warnings will show as they should, and the user will interact with the element like they would a normal input element.
As a user, I might not care to listen to the onChange
event. I may be prototyping.
Especially in the case of the other input types, I often use defaultValue
instead of value
+onChange
Making the fewest assumptions about what the user "meant to do" keeps the library from limiting what they can do
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.
Yeah the only reason why I see onChange not beeing required is just for prototyping because otherwise you have no way to get the value from the input.
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.
Or, one could have a dom listener registered
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.
seriously?! Either you use react, or you don't...
I understand it's nice to be generic, but I think there's a limit to that lol
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.
Not exactly. Take Facebook for example. The majority of the site was done directly mutating dom and they implemented react just for the chat section. There's a reason Facebook doesn't make assumptions about what we meant to do. I can have a full blown site that I just drop in a React component for one piece. That shouldn't break the rest of my app.
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.
Another example is if the user is looking at onClick
instead of onChange
. Or onTouchStart
/onTouchEnd
Assumptions make an opinionated framework and, if I wanted that, I'd use ember or angular
In general, yes we can set the onChange callback as optional. It helps prototyping screen. But usually people will set it anyway because we usually create controlled form. (using value + onChange). |
100% agree - you'll probably will want to register a handler... but you might not. there are a million edge cases where you could be accomplishing the same thing. A use case for not having |
Yep I forgot about this valueLink. But I agree with the changes. I'll merge once I get a confirmation for the tabindex thing. I asked them on their gitter channel. |
Fix: Allow user to provide input props
Fixes #82
event
instead ofvalue
.input
components, where able, are directly passedThere are still some components where value, id, name are handled manually.