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.

SelectInput ignores emptyValue property

See original GitHub issue

What you were expecting: The emptyValue is sent when the empty option is selected in a SelectInput.

What happened instead: An empty string is sent.

Steps to reproduce: Add emptyValue={null} property to a SelectInput.

Related code:

<ReferenceInput source="assignedToId"	reference="users">
	<SelectInput optionText="username" emptyValue={null} />
</ReferenceInput>

When the form loads, {assignedToId: null, …} is received, but when the user clicks save then the form sends {assignedToId: ‘’, …}

Environment

  • React-admin version: 4.2.6
  • Last version that did not exhibit the issue (if applicable):
  • React version: 18.2.0
  • Browser: Chrome
  • Stack trace (in case of a JS error):

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
takayamakicommented, Aug 16, 2022

I encount this problem too.

I tried some cases.

emptyValue="foo" => got "foo"

emptyValue="null" => ignored, got ""
emptyValue={null} => ignored, got ""

emptyValue="1" => got "1"
emptyValue={1} => ignored, got ""

emptyValue="true" => ignored, got ""
emptyValue=true => got true
0reactions
fzaninottocommented, Oct 5, 2022

Besides, <SelectInput> shouldn’t accept null as a possible emptyValue - see #8235.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow empty value "" as choice in selectInput - Stack Overflow
I am developing a shiny application which has a selectInput filter whose choices are coming from a dataframe of NAMES.
Read more >
AutocompleteInput emptyValue prop is ignored #8091 - GitHub
This applies to the SelectInput as well. In your codesandbox, if you change the AutocompleteInput by a SelectInput , you get the same...
Read more >
Input Components - React-admin - Marmelab
Such components allow to edit a record property, and are common in the <Edit> and ... <SelectInput source="category" allowEmpty emptyValue={null} choices={[ ...
Read more >
Should a blank option always be included in <select> inputs?
This way we force the user to think about it and ensure they select the correct option. This helps improve the accuracy of...
Read more >
Custom Filtering • reactable - GitHub Pages
Use reactR::html_dependency_react() to explicitly include this dependency or ... This example shows how you can render a custom <select> input filter in R....
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