question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Setting selected item to null loses placeholder text

See original GitHub issue

Description Setting the bound value to null doesn’t restore the placeholder text.

To Reproduce

  1. 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>
  1. Change HandleFormSubmit as follows:
private void HandleFormSubmit()
{
    Console.WriteLine("Form Submitted Successfully!");
    FormModel.SelectedPerson = null; //I assume this is how you clear the typeahead?
}
  1. 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: image

Actual: image

Hosting Model:

  • Blazor WebAssembly

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
chrissaintycommented, Jun 2, 2021

@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.

0reactions
dsfridayslabcommented, Jul 12, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found