-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[DropDownMenu] [SelectField] Add defaultText
prop shown when there's no item with the corresponding value
#4902
Conversation
Does it work with |
When |
Added the prop also to |
defaultDisplayValue
prop shown when there's no item with the corresponding valuedefaultText
prop shown when there's no item with the corresponding value
@@ -180,6 +185,7 @@ class SelectField extends Component { | |||
<TextField | |||
{...other} | |||
style={style} | |||
defaultText={!hintText && !floatingLabelText ? defaultText : ''} |
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.
maybe !(hintText || floatingLabelText) ?
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.
you're right 👍
@@ -180,6 +185,7 @@ class SelectField extends Component { | |||
<TextField | |||
{...other} | |||
style={style} | |||
defaultText={hintText || floatingLabelText ? '' : defaultText} |
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.
What's the use case for this property?
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.
Well, for all the cases I have, there's a default action when nothing is selected, but I don't want to keep the select box empty. A simple solution would be to specify the text from the first option here as well, as other people still want this select empty for their cases.
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'm asking because defaultText
doesn't seems to have any impact on the TextField
component. And React is throwing a warning about leaking property.
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.
Snap, you're right. It was intended to be passed for DropDownMenu
.
Does this parameter still make sense or we'll use the first option's 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'll use the first option's value?
I think that it would be better without this property. It isn't going to help migrating from a <select />
to a <SelectField />
, nor the other way around, right?
@zalmoxisus As far as I have investigated the issue, we need the But the
const propsLeaf = children ? children.props : this.props;
/**
* This method is deprecated but still here because the TextField
* need it in order to work. TODO: That will be addressed later.
*/
getInputNode() {
const root = this.refs.root;
root.focus = () => {
if (!this.props.disabled) {
this.setState({
open: !this.state.open,
anchorEl: this.refs.root,
});
}
};
return root;
} |
53b828e
to
ea2538e
Compare
I'm closing this PR as quite old now and inactive. Thanks helping us moving forward. |
Redo of #4822.
Normally (at least accordingly to HTML specs), a select box shouldn't be empty, unless you there's an empty option, even if the value doesn't correspond to any item. So, you can specify a string in
defaultText
prop to be shown in this case.