[Bug] Setting selected item to null loses placeholder text
See original GitHub issueDescription Setting the bound value to null doesn’t restore the placeholder text.
To Reproduce
- In sample project, Index.razor, Blazored Typeahead - Form example, change SelectedTemplate to handle null so this doesn’t crash:
<SelectedTemplate Context="person">
@person?.Firstname
</SelectedTemplate>
- Change HandleFormSubmit as follows:
private void HandleFormSubmit()
{
Console.WriteLine("Form Submitted Successfully!");
FormModel.SelectedPerson = null; //I assume this is how you clear the typeahead?
}
- Run sample and submit form. Text clears but placeholder text doesn’t come back.
Expected behavior Placeholder text is restored when bound value is set to null.
Screenshots Expected:
Actual:
Hosting Model:
- Blazor WebAssembly
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How do I make a placeholder for a 'select' box?
Building upon MattW's answer, you can make the select placeholder option visible in the drop-down menu after a valid selection has been made,...
Read more >[v2] Setting value to undefined doesn't show the ...
Setting the value of the select component to null/undefined does not reset the control to a state where the placeholder text is displayed:....
Read more >Don't Use The Placeholder Attribute
For someone who has never encountered it before, placeholder text may look like entered content, causing them to skip over the input.
Read more >Placeholder for a text field - Discussion - BMC Community
Hi,. I am working on cosmetic changes to a form. One of the things in the design was to have placeholders for some...
Read more >On handling NULL values
A: The init option specifies text to show for null. ... Empty fields which are not null have no placeholder text.
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 FreeTop 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
Top GitHub Comments
@kamranghamsari This requires some investigation and I don’t have any free time for this right now. Feel free to look into it and propose a solution.
I had this issue as well. Not sure if the cause is the same, but when I experienced the issue, I was setting the bind-value property to a nullable string with string.Empty as the default value.
I fixed it by removing the default value, so the bound property is null and not empty string.