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
[Select] Add open, onClose and onOpen properties #9844
Conversation
5b74334
to
984c496
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.
It's a good start :)
src/Select/SelectInput.js
Outdated
@@ -27,10 +27,13 @@ class SelectInput extends React.Component { | |||
}); | |||
}; | |||
|
|||
handleClose = () => { | |||
handleClose = e => { |
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.
event
src/Select/SelectInput.js
Outdated
@@ -269,7 +273,7 @@ class SelectInput extends React.Component { | |||
<Menu | |||
id={`menu-${name || ''}`} | |||
anchorEl={this.state.anchorEl} | |||
open={this.state.open} | |||
open={open !== undefined ? open : this.state.open} |
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.
It would be great to use the same logic as with the other components and with how React is handling the topic internally:
https://github.com/mui-org/material-ui/blob/33d0954b8626528fda6eeaa8cc39216ccc3117dd/src/internal/SwitchBase.js#L41
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.
Thanks, ok, working on it, adding tests
isControlled = this.props.open !== undefined;
a72d373
to
b7736ec
Compare
I don't know if you'll like it, because I've not seen it used elsewhere, but I'd like to propose also why isn't |
319c1c9
to
45c3924
Compare
@caub If we go down this path, we gonna need to reflect it on all our components. We need to keep the API predictable. Some component only needs the onClose callback. Personally, I prefer the verbosity and the extra control two different callbacks offer.
I have no clue 😮 . You raise a good issue! |
@@ -98,6 +102,7 @@ class MultipleSelect extends React.Component { | |||
))} | |||
</Select> | |||
</FormControl> | |||
|
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.
We never use a blank line in our JSX. Let's reduce entropy 👼 .
multiple | ||
open={this.state.open} | ||
value={this.state.nameWithClose} | ||
onChange={e => this.setState({ nameWithClose: e.target.value })} |
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.
We encourage people to be more explicit: e
-> event
.
@@ -18,25 +18,37 @@ class SelectInput extends React.Component { | |||
|
|||
ignoreNextBlur = false; | |||
|
|||
isControlled = this.props.open !== undefined; |
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.
Wow, I thought we needed to wait for the constructor call. Maybe not after all!
src/Select/SelectInput.js
Outdated
@@ -351,6 +366,23 @@ SelectInput.propTypes = { | |||
* @ignore | |||
*/ | |||
onFocus: PropTypes.func, | |||
/** | |||
* Callback fired when the component requests to be closed. |
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.
The description is wrong.
Thanks for the notes @oliviertassinari Which are the other Components to handle? I've checked Snackbar, Modal, Dialog, .. they are manageable already also isn't it repetitive to have both TypeScript defs and PropTypes? maybe it's under change one non-important thing I noticed, |
a7e39bd
to
45d6d0b
Compare
45d6d0b
to
16e081b
Compare
@caub We are good.
We haven't found a better tradeoff yet.
How do you reproduce this statement? I can't. |
@caub Thanks |
Oh.. You are right, ignore it :)) |
alternative for #9839
todo tests