Placeholder not visible for empty object as value
See original GitHub issueWhen the value
parameter is given an empty object, placeholder is not visible. I think, along with null
and undefined
values, even empty objects {}
and empty lists []
should be considered as no value.
For the below code, placeholder is not seen. However, when this.state.value
is set as null
or undefined
, placeholder is visible.
var options = [
{value: 'apple', label: 'Apple'},
{value: 'banana', label: 'Banana'}
];
class extends React.Component {
constructor(props) {
super(props);
this.state = {
value: {}
}
}
render() {
return (
<Select
placeholder="Select a fruit"
value={this.state.value}
options={options} />
);
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Unable to set value attribute for placeholder if value is empty ...
Click in the input box. Placeholder value is cleared. Click outside, placeholder value is now reset back. Click in the input box. Type...
Read more >:placeholder-shown - CSS: Cascading Style Sheets | MDN
The :placeholder-shown CSS pseudo-class represents any or element that is currently displaying placeholder text.
Read more >Experience editor does not show the empty placeholder ...
When we add any component in empty placeholder in experience editor and then remove the component, we do not see the the empty...
Read more >Placeholder vs Value Attributes in HTML - GeeksforGeeks
The actual value of the placeholder is empty. Once the user does enter something, the placeholder is no longer needed.
Read more >Zendesk Support placeholders reference
There are two primary data objects in Zendesk Support: Ticket and User. ... Note: If the subject field is empty or not visible...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My code used React, TypeScript with React-Select Async for controlled value, value needs to be null in order for placeholder to display the text
@tejasjadhav Set value as a void string then convert it to a object.